-
Notifications
You must be signed in to change notification settings - Fork 39
Add specific http promise #116
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
Looking at this PR: it actually doesn't solve the problem, because you cannot make sure that these promises are returned. It only provides type safety WHEN they are used. This means that you probably can't assume that the rejection callback will receive an So in this case php-http/client-common#35 is still valid? |
Yes we Will need to replace used promise in emulated client by this one |
That's okay, but even then, we cannot make sure that clients will actually use that promise, so we have to rely on the Promise interface spec, which accepts any exceptions, meaning the rejection callbacks should too. Am I wrong? |
I see your point, however this behavior is already clearly specify in the dockblock :
We can add a HttpPromise (which extends Promise) to enforce this at code level, for me it's not a BC break since we have the same behavior as previously but exprimed at the code level and not on the docblock level (so this like a new feature and can be done in a 1.1.0 version IMO). |
I add the interface with change to the async client |
/** | ||
* {@inheritdoc} | ||
* | ||
* @return HttpPromise A new resolved http promise with value of the executed callback (onFulfilled / onRejected). |
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 is not possible. Think about PHP 7, this line should still be public function then(callable $onFulfilled = null, callable $onRejected = null): Promise;
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.
So this interface is useless ? should we remove it ?
imho we need to solve this by documentation and avoid people using the promise stufff in HTTPlug for other things than HTTP. a promise should be allowed to throw any exception, but further promises in the chain should not be bothered with non-http exceptions. |
95c829d
to
bff98e8
Compare
I agree with that, but then I remove the HttpPromise interface to not having to think about a BC Break (we can do that later) and i also add tests. |
bff98e8
to
67ce613
Compare
What should we do about that ? |
This line causes all our problems IMO: https://github.com/php-http/httplug/pull/116/files#diff-0604cd13cbcbbca1c6eb9241817bb50cR34 I would say let's merge this and use it in client-common. Also, make sure we document this properly (use the above promises and/or don't throw non-http exceptions?) My concern regarding this change: version. We will have to increase version number. How do we handle this in |
The contract does not change so we don't need to upgrade the version of the virtual package, library like common-client would just have to require httplug with ^1.1.0 |
Okay, I vote for merging. WDYT @joelwurtz @Nyholm @dbu ? |
I've tested this and it works. Im 👍 Im trying to figure out the implications of this. It requires updates on
And our Async clients:
Question: What would the new version of HTTPlug be? |
1.1.0 It's a new feature but doesn't break BC Yes we need to update all common-client but it's for a good reason IMO, so not so a problem |
Good. =)
I agree. This PR is a no brainer. 👍 |
And i checked all adapters, their are good and respect the contract as far as i have seen. |
Yeah, So did I. I believe there is path versions for all packages except for php-http/httplug. |
I voted for merge, so did Mark and Joel. David chose to abstain. (See slack). I will merge this PR. Thank you @joelwurtz! |
Does this invalidate php-http/client-common#34? |
Yes, that ticket is invalid. But we still need to be clear with the plugins. Ie increase the docs. |
Okay, so based on @joelwurtz's comment, we only have to merge this, tag this and update the version number in client common (this is only a problem with plugins, right?) |
Clients themselves are okay, right? |
See my previous comment: #116 (comment) I'll make sure to do some PRs tomorrow if nobody beats me to it |
All async client are already good Need to do :
|
This is not something that is meant to merge, it's to offer a point of view on this ticket php-http/client-common#34 we should accept this or not based on the final decision.