-
Notifications
You must be signed in to change notification settings - Fork 39
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
Allow returning a Promise in onRejected then() #168
Allow returning a Promise in onRejected then() #168
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.
thank you for picking up the topic and creating this pull request. this looks good to me.
regarding documentation, i think it would make sense to add an explanation to https://docs.php-http.org/en/latest/components/promise.html
please also add a note to the CHANGELOG.md
and can you please rebase on master? i fixed the CI configuration so that all checks are green again.
836e19f
to
f878059
Compare
@dbu I updated the CHANGELOG and I sent this PR php-http/documentation#295 for the documentation. Thanks! |
@dbu I forgot to mention, I used the |
@dbu anything missing on this PR? Let me know if I can help, thanks. |
thanks a lot! here you go: https://github.com/php-http/httplug/releases/tag/2.3.0 |
Thanks @dbu for the quick release! |
What's in this PR?
This PR allows to return a Promise in the
onRejected
callable function forHttpRejectedPromise
. Right now is only possible to return aResponseInterface
for the$onRejected($this->exception)
call, see here.Why?
I'm proposing this change because I'm trying to implement a retry mechanism for async requests (related to this issue php-http/client-common#112). I did a POC in elastic-transport-php library that is using HTTPlug. See 8.x branch for the details.
Example Usage
Using this change we can easily implements a retry mechanism as follows:
To Do