Class CommandPool
- Aws\CommandPool implements GuzzleHttp\Promise\PromisorInterface
- Namespace: Aws
- Located at CommandPool.php
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.
Methods Summary
-
__construct ( Aws\AwsClientInterface $client, array|\Iterator $commands, array $config = [] )
The CommandPool constructor accepts a hash of configuration options:
- promise ( )
-
static
batch ( Aws\AwsClientInterface $client, mixed $commands, array $config = [] )
Executes a pool synchronously and aggregates the results of the pool into an indexed array in the same order as the passed in array.
Methods Details
__construct (
Aws\AwsClientInterface
$client,
array|Iterator
$commands,
array
$config = []
)
The CommandPool constructor accepts a hash of configuration options:
- 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
Aws\AwsClientInterface |
$client | Client used to execute commands. |
array|Iterator | $commands | Iterable that yields commands. |
array | $config = [] | Associative array of options. |
GuzzleHttp\Promise\PromiseInterface
promise (
)
static
array
batch (
Aws\AwsClientInterface
$client,
mixed
$commands,
array
$config = []
)
Executes a pool synchronously and aggregates the results of the pool into an indexed array in the same order as the passed in array.
Parameters
Aws\AwsClientInterface |
$client | Client used to execute commands. |
mixed | $commands | Iterable that yields commands. |
array | $config = [] | Configuration options. |
Returns
array |
See
\Aws\CommandPool::__construct for available configuration options.