Google Cloud PHP shared dependency, providing functionality useful to all components. Client - Class BatchRunner (1.48.1)

Reference documentation and code samples for the Google Cloud PHP shared dependency, providing functionality useful to all components. Client class BatchRunner.

A class for executing jobs in batch.

Methods

__construct

Determine internal implementation and loads the configuration.

Parameters
NameDescription
configStorage Google\Cloud\Core\Batch\ConfigStorageInterface

[optional] The ConfigStorage object to use. Defaults to null. This is only for testing purpose.

processor Google\Cloud\Core\Batch\ProcessItemInterface

[optional] The processor object to use. Defaults to null. This is only for testing purpose.

registerJob

Register a job for batch execution.

Parameters
NameDescription
identifier string

Unique identifier of the job.

func callable

Any Callable except for Closure. The callable should accept an array of items as the first argument.

options array

Configuration options.

↳ batchSize int

The size of the batch.

↳ callPeriod float

The period in seconds from the last execution to force executing the job.

↳ numWorkers int

The number of child processes. It only takes effect with the {@see}.

↳ bootstrapFile string

A file to load before executing the job. It's needed for registering global functions.

Returns
TypeDescription
booltrue on success, false on failure

submitItem

Submit an item.

Parameters
NameDescription
identifier string

Unique identifier of the job.

item mixed

It needs to be serializable.

Returns
TypeDescription
void

getJobFromId

Get the job with the given identifier.

Parameter
NameDescription
identifier string

Unique identifier of the job.

Returns
TypeDescription
Google\Cloud\Core\Batch\BatchJob|null

getJobFromIdNum

Get the job with the given numeric id.

Parameter
NameDescription
idNum int

A numeric id of the job.

Returns
TypeDescription
Google\Cloud\Core\Batch\BatchJob|null

getJobs

Get all the jobs.

Returns
TypeDescription
array<Google\Cloud\Core\Batch\BatchJob>

loadConfig

Load the config from the storage.

Returns
TypeDescription
booltrue on success

getProcessor

Gets the item processor.

Returns
TypeDescription
Google\Cloud\Core\Batch\ProcessItemInterface