-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Description
Since quite some time Guzzle added support for async requests:
https://docs.guzzlephp.org/en/stable/quickstart.html#async-requests
It is also available in the code base we ship, but currently not accessible as we wrap away guzzle with our
server/lib/private/Http/Client/Client.php
Line 51 in 8aea25b
| class Client implements IClient { |
Async requests would come in very handy and could help to speed up several requests were we don't care about the outcome, e.g. potential webhooks.
A method like the following would work
public function postAsync(string $uri, array $options = []): void {
$this->preventLocalAddress($uri, $options);
if (isset($options['body']) && is_array($options['body'])) {
$options['form_params'] = $options['body'];
unset($options['body']);
}
$this->client->requestAsync('post', $uri, $this->buildRequestOptions($options));
}but it hides away the Promise option. But if we'd expose that, it would mean more wrapping or exposing Guzzle.
Unluckily the Async stuff is not part of the PSR, so we can't write a generic wrapper for that.
Other current solutions:
- Make the app/server depend on Guzzle directly
- Ignoring user cancel and send the output while the process continues afterwards: https://github.com/nextcloud/circles/blob/96447086eca1b4dfba21b05f750de3f9c13e605e/lib/Service/MiscService.php#L358-L370
Any preferences?
cc @come-nc @ChristophWurst