Batch
class Batch mixin Factory (View source)
Properties
protected Factory | $factory | The factory instance. |
|
protected PendingRequest> | $requests | The array of requests. |
|
$totalRequests | The total number of requests that belong to the batch. |
||
$pendingRequests | The total number of requests that are still pending. |
||
$failedRequests | The total number of requests that have failed. |
||
protected callable | $handler | The handler function for the Guzzle client. |
|
protected | $beforeCallback | The callback to run before the first request from the batch runs. |
|
protected | $progressCallback | The callback to run after a request from the batch succeeds. |
|
protected | $catchCallback | The callback to run after a request from the batch fails. |
|
protected | $thenCallback | The callback to run if all the requests from the batch succeeded. |
|
protected | $finallyCallback | The callback to run after all the requests from the batch finish. |
|
protected bool | $inProgress | If the batch already was sent. |
|
CarbonImmutable | $createdAt | The date when the batch was created. |
|
CarbonImmutable|null | $finishedAt | The date when the batch finished. |
Methods
Create a new request batch instance.
Add a request to the batch with a key.
Send all of the requests in the batch.
Retrieve a new async pending request.
Get the total number of requests that have been processed by the batch thus far.
Determine if the batch has finished executing.
Increment the count of total and pending requests in the batch.
Decrement the count of pending requests in the batch.
Determine if the batch has job failures.
Increment the count of failed requests in the batch.
Get the requests in the batch.
Add a request to the batch with a numeric index.
Details
void
__construct(Factory|null $factory = null)
Create a new request batch instance.
PendingRequest
as(string $key)
Add a request to the batch with a key.
Batch
before(Closure $callback)
Register a callback to run before the first request from the batch runs.
Batch
progress(Closure $callback)
Register a callback to run after a request from the batch succeeds.
Batch
then(Closure $callback)
Register a callback to run after all the requests from the batch succeed.
Batch
finally(Closure $callback)
Register a callback to run after all the requests from the batch finish.
array
send()
Send all of the requests in the batch.
protected PendingRequest
asyncRequest()
Retrieve a new async pending request.
int
processedRequests()
Get the total number of requests that have been processed by the batch thus far.
bool
finished()
Determine if the batch has finished executing.
protected void
incrementPendingRequests()
Increment the count of total and pending requests in the batch.
protected void
decrementPendingRequests()
Decrement the count of pending requests in the batch.
bool
hasFailures()
Determine if the batch has job failures.
protected void
incrementFailedRequests()
Increment the count of failed requests in the batch.
array
getRequests()
Get the requests in the batch.
PendingRequest|Promise
__call(string $method, array $parameters)
Add a request to the batch with a numeric index.