WorkerCtrl
in package
Functions to update and report on worker status
Table of Contents
Methods
- findPhp() : array<string|int, mixed>
- Looks in a few places for a PHP CLI binary
- getPdb() : Pdb
- Get a Pdb instance for use with worker jobs.
- getQueue() : QueueInterface
- Get a queue instance for use with worker jobs.
- getStatus() : array{status: "Prepared"|"Running"|"Success"|"Failed", metric1val: int, metric2val: int, metric3val: int}
- Return the status and metric values for a given worker job.
- push() : string
- Push a job to the queue.
- runQueue() : bool
- Run the worker queue for a given channel.
- start() : array<string|int, mixed>
- Starts a new worker Workers are run in their own process (using the PHP CLI)
- execute() : Process
- Execute a worker job.
Methods
findPhp()
Looks in a few places for a PHP CLI binary
public
static findPhp() : array<string|int, mixed>
Return values
array<string|int, mixed> —[path, version]
getPdb()
Get a Pdb instance for use with worker jobs.
public
static getPdb() : Pdb
This is a separate instance to skirt past transactions.
Return values
PdbgetQueue()
Get a queue instance for use with worker jobs.
public
static getQueue([string $group = 'default' ]) : QueueInterface
Parameters
- $group : string = 'default'
Return values
QueueInterfacegetStatus()
Return the status and metric values for a given worker job.
public
static getStatus(int $job_id) : array{status: "Prepared"|"Running"|"Success"|"Failed", metric1val: int, metric2val: int, metric3val: int}
Statuses are: 'Prepared', 'Running', 'Success', 'Failed'.
Parameters
- $job_id : int
Return values
array{status: "Prepared"|"Running"|"Success"|"Failed", metric1val: int, metric2val: int, metric3val: int}push()
Push a job to the queue.
public
static push(JobInterface $job[, array<string|int, mixed> $options = [] ]) : string
Options are specific to the queue implementation, default is WorkerQueue.
- timeout: in seconds (default 300)
- priority: smaller numbers are executed first (default 100)
An additional 'channel' option will change the target queue.
Parameters
- $job : JobInterface
- $options : array<string|int, mixed> = []
Tags
Return values
stringrunQueue()
Run the worker queue for a given channel.
public
static runQueue(string $channel[, int $timeout = 10 ][, callable|null $logger = null ]) : bool
The channel must use an instance of WorkerQueue.
Parameters
- $channel : string
- $timeout : int = 10
-
in seconds (default 10)
- $logger : callable|null = null
Return values
boolstart()
Starts a new worker Workers are run in their own process (using the PHP CLI)
public
static start(string $class_name, mixed ...$args) : array<string|int, mixed>
The first argument is the class name Additional arguments can be provided directly in the function call
Return value is an array with the following keys job_id The ID of the new job log_url URL to view ongoing status and log
Parameters
- $class_name : string
- $args : mixed
-
Additional arguments are passed to the
runcall
Tags
Return values
array<string|int, mixed> —Job details
execute()
Execute a worker job.
protected
static execute(array<string|int, mixed> $job) : Process
Parameters
- $job : array<string|int, mixed>
-
db row