class Pool

Properties

protected Request>|Request> $requests

The requests or request producer.

protected null|Response, array-key): void $responseHandler

The successful response handler.

protected null|Throwable, array-key): void $exceptionHandler

The request exception handler.

Methods

__construct(Connector $connector, iterable|callable $requests = [], int $concurrency = 5, callable|null $responseHandler = null, callable|null $exceptionHandler = null)

Create a request pool.

setRequests(iterable|callable $requests)

Set the pool requests.

iterable
requests()

Get the configured requests.

setConcurrency(int $concurrency)

Set the maximum number of concurrent requests.

withResponseHandler(callable $handler)

Register a successful response handler.

withExceptionHandler(callable $handler)

Register a request exception handler.

array
send()

Send every request and collect successful responses.

void
process()

Process every request without retaining successful responses.

array
execute(bool $collectResponses)

Execute the pool in the current or a new root coroutine.

array
orchestrate(bool $collectResponses)

Schedule the requests and settle every started child.

array
keyResults(array $results)

Rebuild results in input order using normal PHP key semantics.

Details

at line 49
__construct(Connector $connector, iterable|callable $requests = [], int $concurrency = 5, callable|null $responseHandler = null, callable|null $exceptionHandler = null)

Create a request pool.

Parameters

Connector $connector
iterable|callable $requests
int $concurrency
callable|null $responseHandler
callable|null $exceptionHandler

at line 74
Pool setRequests(iterable|callable $requests)

Set the pool requests.

Parameters

iterable|callable $requests

Return Value

Pool

at line 86
iterable requests()

Get the configured requests.

Return Value

iterable

at line 98
Pool setConcurrency(int $concurrency)

Set the maximum number of concurrent requests.

Parameters

int $concurrency

Return Value

Pool

at line 115
Pool withResponseHandler(callable $handler)

Register a successful response handler.

Parameters

callable $handler

Return Value

Pool

at line 128
Pool withExceptionHandler(callable $handler)

Register a request exception handler.

Parameters

callable $handler

Return Value

Pool

at line 140
array send()

Send every request and collect successful responses.

Return Value

array

at line 148
void process()

Process every request without retaining successful responses.

Return Value

void

at line 158
protected array execute(bool $collectResponses)

Execute the pool in the current or a new root coroutine.

Parameters

bool $collectResponses

Return Value

array

at line 187
protected array orchestrate(bool $collectResponses)

Schedule the requests and settle every started child.

Parameters

bool $collectResponses

Return Value

array

at line 291
protected array keyResults(array $results)

Rebuild results in input order using normal PHP key semantics.

Parameters

array $results

Return Value

array