-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[HttpClient] Async HTTPlug client #33743
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
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.
I copied some code from Psr18Client
. If someone got suggestion how to share code between Psr18Client
, HttplugClient
and CorePromise
Im happy to update this PR.
addfa6f
to
668e09b
Compare
89312ca
to
f5e1496
Compare
f647abe
to
02d7aac
Compare
5e63313
to
0cbe120
Compare
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.
As discussed on Slack, I rewrote the promise part: the previous logic was copied from https://github.com/php-http/curl-client/blob/master/src/PromiseCore.php yet the logic there is completely broken (see php-http/curl-client#59 and unlike guzzle6-adapter which uses Guzzle promises and thus works as expected.)
The new HttplugPromise
implements the correct logic (hopefuly ;) ), has a cancel()
method and is compatible with Guzzle promises.
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.
I found two small things. I’ll continue test running this code tomorrow.
1444872
to
067ffcd
Compare
31449b9
to
2d3a241
Compare
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.
PR is ready.
It implements HttpAsyncClient::sendAsyncRequest()
and provides two extensions:
HttplugPromise::cancel()
allows cancelling a promise (and the underlying response)HttplugClient::wait()
allows to tick the promise pool, with configurable timeouts.
I pushed two small bugfixes. Im happy with this PR now |
9f6f7c6
to
4fd593f
Compare
Thank you @Nyholm. |
|
||
public function cancel(): void | ||
{ | ||
$this->promise->cancel(); |
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.
shouldn't this also call the cancel callback ?
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.
the guzzle promise will call it already
…() (nicolas-grekas) This PR was merged into the 4.4 branch. Discussion ---------- [HttpClient] resolve promise chains on HttplugClient::wait() | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | Fix #32142 | License | MIT | Doc PR | - Follow up of #33743 Right now, keeping a reference to promise objects returned by `HttplugClient::sendAsyncRequest()`, then calling their `wait()` method is the only way to actually resolve the promises. That's why when these promises are destructed, we cancel the corresponding HTTP request. But thanks to the `HttplugClient::wait()` method, we have a hook to tick the event loop managed by the Symfony client. I added a test case to run into this situation. ~It fails currently. I'd like asking @joelwurtz, @dbu and/or maybe @Nyholm if you could have a look and finish this PR? I'm not that familiar with promises and you might get faster and better to the goal. Anyone else is welcome also of course. Thank you for having a look :) PR welcome on my fork or as a separate one on this repos.~ Commits ------- ea0be07 [HttpClient] resolve promise chains on HttplugClient::wait()
…holm, nicolas-grekas) This PR was merged into the 4.4 branch. Discussion ---------- Adapted the HTTPlug integration docs to Async Client This should be merged with symfony/symfony#33743 Closes #12472 Closes #12475 Commits ------- d353b61 Complete doc for 4.4 features 7295404 Adapted the HTTPlug integration docs to Async Client
…ntation (Taluu) This PR was merged into the 4.4 branch. Discussion ---------- States that the HttpClient provides a Http Async implementation | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no (not really) | New feature? | no (not really) | Deprecations? | no | Tickets | ~ | License | MIT | Doc PR | ~ Add in the composer.json of the HttpClient that it now provides an implementation for the `php-http/async-client-implementation` virtual package, as @Nyholm did the implementation on the HttpPlug bridge in #33743. Commits ------- 8a460ce States that the HttpClient provides a Http Async implementation
This PR removes
HttplugClient
's dependency onPsr18Client
. It will also add anHttplugPromise
to make sure we sure we respect the Httplug'sHttpAsyncClient
interface.It implements
HttpAsyncClient::sendAsyncRequest()
and provides two extensions:HttplugPromise::cancel()
allows cancelling a promise (and the underlying response)HttplugClient::wait()
allows to tick the promise pool, with configurable timeouts.