Core/src/Batch/BatchRunner.php
public function registerJob($identifier, $func, array $options = [])
    {
        if ($func instanceof \Closure) {
            throw new \InvalidArgumentException('Closure is not allowed');
        }
        // Always work on the latest data
        $result = $this->configStorage->lock();
        if ($result === false) {
            return false;
        }
        $this->config = $this->configStorage->load();
        $this->config->registerJob(
            $identifier,
            function ($id) use ($identifier, $func, $options) {
                return new BatchJob($identifier, $func, $id, $options);
            }
        );

        try {
            $result = $this->configStorage->save($this->config);
        } finally {
            $this->configStorage->unlock();
        }
        return $result;
    }
public function registerJob($identifier, $func, array $options = [])
    {
        if ($func instanceof \Closure) {
            throw new \InvalidArgumentException('Closure is not allowed');
        }
        // Always work on the latest data
        $result = $this->configStorage->lock();
        if ($result === false) {
            return false;
        }
        $this->config = $this->configStorage->load();
        $this->config->registerJob(
            $identifier,
            function ($id) use ($identifier, $func, $options) {
                return new BatchJob($identifier, $func, $id, $options);
            }
        );

        try {
            $result = $this->configStorage->save($this->config);
        } finally {
            $this->configStorage->unlock();
        }
        return $result;
    }
public function registerJob ( $ identifier , $ func , array $ options = [ ] ) { if ( $ func instanceof \ Closure ) { throw new \ InvalidArgumentException ( 'Closure is not allowed' ) ; } // Always work on the latest data $ result = $ this -> configStorage -> lock ( ) ; if ( $ result === false ) { return false ; } $ this -> config = $ this -> configStorage -> load ( ) ; $ this -> config -> registerJob ( $ identifier , function ( $ id ) use ( $ identifier , $ func , $ options ) { return new BatchJob ( $ identifier , $ func , $ id , $ options ) ; } ) ; try { $ result = $ this -> configStorage -> save ( $ this -> config ) ; } finally { $ this -> configStorage -> unlock ( ) ; } return $ result ; }
Register a job for batch execution.

@param string $identifier Unique identifier of the job.
@param callable $func Any Callable except for Closure. The callable
should accept an array of items as the first argument.
@param array $options [optional] {
Configuration options.

@type int $batchSize The size of the batch.
@type float $callPeriod The period in seconds from the last execution
to force executing the job.
@type int $numWorkers The number of child processes. It only takes
effect with the {@see \Google\Cloud\Core\Batch\BatchDaemon}.
@type string $bootstrapFile A file to load before executing the
job. It's needed for registering global functions.
}
@return bool true on success, false on failure
@throws \InvalidArgumentException When receiving a Closure.
Register a job for batch execution .