Skip to content
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

Start to support php-http #91

Merged
merged 2 commits into from Feb 19, 2017
Merged

Conversation

tyx
Copy link
Member

@tyx tyx commented Feb 10, 2017

Thanks to @iamluc the implementation was trivial.

However, this one will not support real async as php-http does not implement it.

Missing points

  • Spec on RequestServerErrorVoter
  • Spec on StatusCodeVoter
  • Doc

In order to use the same feature through different implementation
composer.json Outdated
@@ -7,7 +7,8 @@
"require": {
"ramsey/uuid": "^3.1",
"symfony/psr-http-message-bridge": "^1.0",
"zendframework/zend-diactoros": "^1.3"
"zendframework/zend-diactoros": "^1.3",
"php-http/mock-client": "^0.3.3"

Choose a reason for hiding this comment

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

Is there any specific reason this is not a dev requirement? It's for testing.

@@ -105,6 +105,11 @@ private function onTerminate(PromiseOperation $operation, ThrowableCatcherVoter
return $fulfilled ? new FulfilledPromise($value) : new RejectedPromise($value);
}

// If it is a php http Promise, use php http's objects.
if ($promise instanceof \Http\Promise\Promise) {
return $fulfilled ? new \Http\Client\Promise\HttpFulfilledPromise($value) : new \Http\Client\Promise\HttpRejectedPromise($value);

Choose a reason for hiding this comment

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

I think there is some confusion here: $promise here is the same as you call the on terminate callback on. Why? Since RetryPromiseOperationRunner::run returns a promise which receives a promise in it's callback, $value itself in this case will be a promise, likely unresolved.

Why do you need to specifically set Fulfilled/Rejected promises here? It's useful when you already know the resolution which actually you don't: $promise is fulfilled, but there is no guarantee that $value is too, so you will have to call ->wait() here as @joelwurtz pointed, but in that case you will loose real async.

But I would advise reviewing how promises work, seems to be a bit complicated to me. There are a few examples in PHP-HTTP documentation, Guzzle is a bit more sophisticated, but basically the same, you might want to check it's documentation out too.

Copy link
Member

@sroze sroze left a comment

Choose a reason for hiding this comment

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

That's perfect, thank you very much @tyx! Great work 👏

@sroze sroze merged commit 82d9a16 into Tolerance:master Feb 19, 2017
@sroze sroze mentioned this pull request Feb 19, 2017
@tyx tyx deleted the feature/support-php-http branch September 4, 2017 15:21
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.

None yet

3 participants