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

How to send concurrent requests? #105

Closed
mxr576 opened this issue May 10, 2018 · 5 comments
Closed

How to send concurrent requests? #105

mxr576 opened this issue May 10, 2018 · 5 comments

Comments

@mxr576
Copy link
Contributor

mxr576 commented May 10, 2018

Is there a way to send concurrent requests and wait for their results in a same way as Guzzle supports?
Ex.: Load entities by ids in a function from on API that can only load entities one by one.

(#7 Might be related to this question.)

@mxr576
Copy link
Contributor Author

mxr576 commented May 10, 2018

Okay, it seems Httplug promises and \GuzzleHttp\Promise\settle() and \GuzzleHttp\Promise\unwrap() are working fine together, so let me rephrase my question. How can my code remain client agnostic if I would like to implement the above mentioned example with another client adapter? Should I require and use guzzlehttp/promises for curl, react and others too?

@mxr576
Copy link
Contributor Author

mxr576 commented May 10, 2018

Tested cUrl adapter, it seems this one also working with Guzzle promises (not so surprisingly). Haven't tested other one.

@mxr576 mxr576 closed this as completed May 10, 2018
@dbu
Copy link
Contributor

dbu commented May 11, 2018

glad you found a solution. the recommended way of doing this is using the HttpAsyncClient with a request, which returns you a php-http/promise . see http://docs.php-http.org/en/latest/components/promise.html

(for background: there should be a PSR - or even better a PHP language level solution - for promises. a PSR once started but so far has not been released, so we had to do our own promises for php-http.)

@mxr576
Copy link
Contributor Author

mxr576 commented May 11, 2018

@dbu Any estimate when the "own promises for php-http" could actually happen? Is there a related issue that I can follow?

@dbu
Copy link
Contributor

dbu commented May 11, 2018

not sure i understand the question. the doc i linked explains how to use the php-http promises. they exist already, so nothing needs to "actually happen" ;-)

for the promise PSR, i don't think there is a single issue to watch, you'll have to watch the FIG announcements to see if something happens there.

btw, i noticed that there is another section in the doc on sending asynchronous requests: http://docs.php-http.org/en/latest/httplug/tutorial.html#using-an-asynchronous-client

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

No branches or pull requests

2 participants