Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Prefer the sync call if possible #33

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

Merged
merged 2 commits into from
Dec 26, 2015
Merged

Conversation

joelwurtz
Copy link
Member

See #14

@sagikazarmark sagikazarmark changed the title Prefere the sync call if possible Prefer the sync call if possible Dec 25, 2015
@@ -62,9 +65,20 @@ public function __construct($client, array $plugins = [], array $options = [])
*/
public function sendRequest(RequestInterface $request)
{
$promise = $this->sendAsyncRequest($request);
if (!($this->client instanceof HttpClient)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we just emulate a sync client if an async client is passed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes we can, but by doing this we save many calls, from sync to async and async to sync.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't matter IMO. If we emulate a sync client as well, this condition and call becomes unnecessary.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The emulation add a non necessary layer of code in this case.

As we will have a emulated sync call, which transform promise into a response / exception which is then transformed into promise, and then retransformed into response / exception.

Here we only do the conversion from promise to response / exception once.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I meant async emulation here. We don't need sync emulation IMO. There you also have only one conversion (like now).

@sagikazarmark
Copy link
Member

See php-http/client-common#2

joelwurtz added a commit that referenced this pull request Dec 26, 2015
@joelwurtz joelwurtz merged commit 6bb56db into master Dec 26, 2015
@joelwurtz joelwurtz deleted the feature/prefer-sync-call branch December 26, 2015 16:10
@dbu
Copy link
Contributor

dbu commented Dec 29, 2015

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants