Concurrency across multiple connectors #289
Replies: 1 comment 2 replies
-
Hey @henninghorn thank you for the kind words! ❤️ So this is something that I've actually been curious about for a while myself. It all depends on how Guzzle handles the concurrent requests internally. I **believe that when you send an asynchronous request, it uses the "cURL Multi Handler" in Guzzle, although I may be wrong here. I think this handler keeps the connections open allowing you to make multiple requests on the same connection, which is how you get the speed increase. When I built the Pooling functionality in Saloon I first understood how it works, and it turns out that the "concurrency" part is mainly handled by Guzzle's promise library - it can invoke multiple promises at once. There must be some magic going on behind the scenes because I'm not sure how the promise library interacts with the HTTP client. This would definitely be something worth looking into! However, to test your theory - Saloon's pools accept either a request or a // As the pool requires a connector you have to provide it with a connector like this.
$pool = $hotelOneConnector->pool([
// Then use your other connector to create the promises
$hotelOneConnector->sendAsync(new SearchRoomAvailability),
$hotelTwoConnector->sendAsync(new SearchRoomAvailability),
$hotelThreeConnector->sendAsync(new SearchRoomAvailability),
]); You can set your concurrency as normal. Let me know how that goes! |
Beta Was this translation helpful? Give feedback.
-
Hi!
First of all, Saloon is such a joy to work with!
I'm working with multiple API's and at one point I need to check availability across different hotels using different connectors.
E.g. hotel A and B uses API A, but hotel C and D, uses software B and C.
So a total of four requests across three different API's.
I've read https://docs.saloon.dev/digging-deeper/concurrency-and-pools, but it doesn't seem to be possible to create a pool of requests across multiple connectors.
Can it be achieved in some way?
Best regards
Beta Was this translation helpful? Give feedback.
All reactions