Skip to content

Exposing GuzzleHttp\Client::asyncRequest() #35959

@nickvergessen

Description

@nickvergessen

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

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:

Any preferences?
cc @come-nc @ChristophWurst

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions