jira-api-restclient icon indicating copy to clipboard operation
jira-api-restclient copied to clipboard

Set timeout for fail gracefully

Open ish1301 opened this issue 8 years ago • 7 comments
trafficstars

Sometime JIRA server is down/moved and API takes forever to respond. So consistent timeout address this issue and fail with message that "JIRA server have timed out after 30000 mili seconds"

ish1301 avatar Sep 12 '17 20:09 ish1301

Please do this:

  1. add protected $timeout; property to CurlClient class
  2. add optional $timeout = null parameter to CurlClient class constructor, that will be assigned to that $timeout class property
  3. if $this->timeout is numeric, then set timeout on curl resource
  4. add tests to confirm, that timeout is respected
  5. add note to CHANGELOG.md file
  6. rebase (once #161 is merged) to avoid failing PHP 5.3 tests

This would avoid BC break with enforced timeout of 30 seconds.

aik099 avatar Sep 13 '17 07:09 aik099

@ish1301 , I saw new commit, but it does only part of requested changes. I guess more commits are coming. Anyway, when you're ready to for code review just leave a message in here.

aik099 avatar Nov 13 '17 14:11 aik099

I can't do 2nd step, because that will force me to change ClientInterface and timeout can't be applied to other classes e.g. PHPClient.php

The only way to change timeout is $this->api->client->timeout = 30;

ish1301 avatar Nov 13 '17 15:11 ish1301

I can't do 2nd step, because that will force me to change ClientInterface

I haven't said, that you need to change ClientInterface. I said, that you need to change CurlClient class constructor (which isn't part of the ClientInterface interface) so that you can specify curl-specific timeout. The timeout should be anything present in all client interface implementing parties.

The only way to change timeout is $this->api->client->timeout = 30;

That won't do of course.

aik099 avatar Nov 13 '17 20:11 aik099

Adding new parameter sendRequest() function returns below error, because it expects sendRequest() function to be exact structure as it's in ClientInterface

Declaration must be compatible with ClientInterface->sendRequest

ish1301 avatar Nov 13 '17 20:11 ish1301

screen shot 2017-11-13 at 3 45 34 pm

ish1301 avatar Nov 13 '17 20:11 ish1301

Adding new parameter sendRequest() function returns below error, because it expects sendRequest() function to be exact structure as it's in ClientInterface

Declaration must be compatible with ClientInterface->sendRequest

Again I don't see where I requested to change that method signature.

Please don't do things that aren't requested.

aik099 avatar Nov 14 '17 06:11 aik099