Documentation

CommandPool
in package
implements PromisorInterface

Sends and iterator of commands concurrently using a capped pool size.

The pool will read command objects from an iterator until it is cancelled or until the iterator is consumed.

Interfaces, Classes and Traits

PromisorInterface
Interface used with classes that return a promise.

Table of Contents

$each  : EachPromise
__construct()  : mixed
The CommandPool constructor accepts a hash of configuration options:
batch()  : array<string|int, mixed>
Executes a pool synchronously and aggregates the results of the pool into an indexed array in the same order as the passed in array.
promise()  : PromiseInterface
Returns a promise.
cmpCallback()  : mixed
Adds an onFulfilled or onRejected callback that aggregates results into an array. If a callback is already present, it is replaced with the composed function.
getBefore()  : callable

Properties

Methods

__construct()

The CommandPool constructor accepts a hash of configuration options:

public __construct(AwsClientInterface $client, array<string|int, mixed>|Iterator $commands[, array<string|int, mixed> $config = [] ]) : mixed
  • concurrency: (callable|int) Maximum number of commands to execute concurrently. Provide a function to resize the pool dynamically. The function will be provided the current number of pending requests and is expected to return an integer representing the new pool size limit.
  • before: (callable) function to invoke before sending each command. The before function accepts the command and the key of the iterator of the command. You can mutate the command as needed in the before function before sending the command.
  • fulfilled: (callable) Function to invoke when a promise is fulfilled. The function is provided the result object, id of the iterator that the result came from, and the aggregate promise that can be resolved/rejected if you need to short-circuit the pool.
  • rejected: (callable) Function to invoke when a promise is rejected. The function is provided an AwsException object, id of the iterator that the exception came from, and the aggregate promise that can be resolved/rejected if you need to short-circuit the pool.
  • preserve_iterator_keys: (bool) Retain the iterator key when generating the commands.
Parameters
$client : AwsClientInterface

Client used to execute commands.

$commands : array<string|int, mixed>|Iterator

Iterable that yields commands.

$config : array<string|int, mixed> = []

Associative array of options.

Return values
mixed

batch()

Executes a pool synchronously and aggregates the results of the pool into an indexed array in the same order as the passed in array.

public static batch(AwsClientInterface $client, mixed $commands[, array<string|int, mixed> $config = [] ]) : array<string|int, mixed>
Parameters
$client : AwsClientInterface

Client used to execute commands.

$commands : mixed

Iterable that yields commands.

$config : array<string|int, mixed> = []

Configuration options.

Tags
see
CommandPool::__construct

for available configuration options.

Return values
array<string|int, mixed>

cmpCallback()

Adds an onFulfilled or onRejected callback that aggregates results into an array. If a callback is already present, it is replaced with the composed function.

private static cmpCallback(array<string|int, mixed> &$config,  $name, array<string|int, mixed> &$results) : mixed
Parameters
$config : array<string|int, mixed>
$name :
$results : array<string|int, mixed>
Return values
mixed

getBefore()

private getBefore(array<string|int, mixed> $config) : callable
Parameters
$config : array<string|int, mixed>
Return values
callable

Search results