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

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.

Namespace

Google \ Cloud \ Core \ Batch

Methods

__construct

Determine internal implementation and loads the configuration.

Parameters
Name Description
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
Name Description
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 Google\Cloud\Core\Batch\BatchDaemon.

↳ bootstrapFile string

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

Returns
Type Description
bool true on success, false on failure

submitItem

Submit an item.

Parameters
Name Description
identifier string

Unique identifier of the job.

item mixed

It needs to be serializable.

Returns
Type Description
void

getJobFromId

Get the job with the given identifier.

Parameter
Name Description
identifier string

Unique identifier of the job.

Returns
Type Description
Google\Cloud\Core\Batch\BatchJob|null

getJobFromIdNum

Get the job with the given numeric id.

Parameter
Name Description
idNum int

A numeric id of the job.

Returns
Type Description
Google\Cloud\Core\Batch\BatchJob|null

getJobs

Get all the jobs.

Returns
Type Description
array<Google\Cloud\Core\Batch\BatchJob>

loadConfig

Load the config from the storage.

Returns
Type Description
bool true on success

getProcessor

Gets the item processor.

Returns
Type Description
Google\Cloud\Core\Batch\ProcessItemInterface