-
-
Notifications
You must be signed in to change notification settings - Fork 38
Added Timeout-Promise to Transaction #90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@Rakdar Thank you for taking the time to file this PR! I've just posted a small recap for this feature in #1 (comment), what do you think about this? I'm currently undecided if we can apply a "default timeout" here and if so, what its timeout value should be. Any input is welcome! 👍 |
clue
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the discussion in #1, so let's finally see what needs to be done to get this in! ![]()
src/Io/Transaction.php
Outdated
| public function __construct(RequestInterface $request, Sender $sender, array $options = array(), MessageFactory $messageFactory) | ||
| { | ||
| /** @var int $timeout */ | ||
| private $timeout = 10; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure about this default value, how about using http://php.net/manual/en/filesystem.configuration.php#ini.default-socket-timeout instead? (defaults to 60s)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, you're right. Using the ini-default-value as default will be better. (I personally just don't like a 60 seconds timeout; what server takes 60 seconds to send the headers? ... in 2018?)
src/Io/Transaction.php
Outdated
| function (ResponseInterface $response) use ($request, $that) { | ||
| return $that->onResponse($response, $request); | ||
| } | ||
| return Promise\Timer\timeout( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This only times out a single request within this "transaction". In other words: This timeout will be restarted for each redirection and the consumer has no control over applying a total timeout.
It's my understanding that this timeout should apply to the whole "transaction", i.e. simply move this up to the send() method instead of the next() method.
What do you think about this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now i don't get it myself why i implemented the timeout within the next() method.
- Moving timeout-promise one method up to send() instead of next().
In relation to #1, i implemented a promise-timer to support timeouts.
The default is 10 seconds and the API implemented as suggested: