Open Journal Systems  3.3.0
GuzzleHttp\Pool Class Reference
Inheritance diagram for GuzzleHttp\Pool:
GuzzleHttp\Promise\PromisorInterface

Public Member Functions

 __construct (ClientInterface $client, $requests, array $config=[])
 
 promise ()
 

Static Public Member Functions

static batch (ClientInterface $client, $requests, array $options=[])
 

Detailed Description

Sends an iterator of requests concurrently using a capped pool size.

The pool will read from an iterator until it is cancelled or until the iterator is consumed. When a request is yielded, the request is sent after applying the "request_options" request options (if provided in the ctor).

When a function is yielded by the iterator, the function is provided the "request_options" array that should be merged on top of any existing options, and the function MUST then return a wait-able promise.

Definition at line 20 of file Pool.php.

Constructor & Destructor Documentation

◆ __construct()

GuzzleHttp\Pool::__construct ( ClientInterface  $client,
  $requests,
array  $config = [] 
)
Parameters
ClientInterface$clientClient used to send the requests.
array | \Iterator$requestsRequests or functions that return requests to send concurrently.
array$configAssociative array of options
  • concurrency: (int) Maximum number of requests to send concurrently
  • options: Array of request options to apply to each request.
  • fulfilled: (callable) Function to invoke when a request completes.
  • rejected: (callable) Function to invoke when a request is rejected.

Definition at line 38 of file Pool.php.

References GuzzleHttp\Promise\each().

Member Function Documentation

◆ batch()

static GuzzleHttp\Pool::batch ( ClientInterface  $client,
  $requests,
array  $options = [] 
)
static

Sends multiple requests concurrently and returns an array of responses and exceptions that uses the same ordering as the provided requests.

IMPORTANT: This method keeps every request and response in memory, and as such, is NOT recommended when sending a large number or an indeterminate number of requests concurrently.

Parameters
ClientInterface$clientClient used to send the requests
array | \Iterator$requestsRequests to send concurrently.
array$optionsPasses through the options available in {
See also
GuzzleHttp\Pool::__construct}
Returns
array Returns an array containing the response or an exception in the same order that the requests were sent.
Exceptions

Definition at line 103 of file Pool.php.

◆ promise()

GuzzleHttp\Pool::promise ( )

Get promise

Returns
PromiseInterface

Implements GuzzleHttp\Promise\PromisorInterface.

Definition at line 81 of file Pool.php.

References GuzzleHttp\Promise\each().


The documentation for this class was generated from the following file: