-
Notifications
You must be signed in to change notification settings - Fork 6
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
Conversation
@@ -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)) { |
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 we just emulate a sync client if an async client is passed?
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 we can, but by doing this we save many calls, from sync to async and async to sync.
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.
It doesn't matter IMO. If we emulate a sync client as well, this condition and call becomes unnecessary.
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 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.
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.
Sorry, I meant async emulation here. We don't need sync emulation IMO. There you also have only one conversion (like now).
Prefer the sync call if possible
👍 |
See #14