WorkerQueue
in package
implements
ConfigurableInterface, QueueInterface
uses
UpdateTrait
A queue of worker jobs.
This executes jobs one-by-one, in the order they were added.
Tags
Table of Contents
Interfaces
- ConfigurableInterface
- This class is 'configurable' - it has an `update()` method that accepts iterables.
- QueueInterface
- A queue for processing jobs.
Properties
- $channel : string
- A channel group for jobs.
- $immediate : bool
- Start the queue immediately on push().
- $job_interval : float
- Interval in seconds to wait after processing a job (when queue is busy)
- $poll_interval : float
- Interval in seconds between polling the DB for new jobs (when queue has been empty)
- $priority : int
- A default priority.
- $timeout : int
- A default timeout.
Methods
- pop() : JobInterface|null
- Get the next job from the queue.
- push() : string
- Push a job onto the queue.
- update() : void
- executeQueue() : void
- Run the queue immediately.
- insertJob() : int
- Insert a job into the database.
Properties
$channel
A channel group for jobs.
public
string
$channel
This must be unique. If not specified, uses the group name (i.e. default).
$immediate
Start the queue immediately on push().
public
bool
$immediate
= true
Otherwise the queue must be managed externally by a service, e.g. supervisord, systemd, etc.
$job_interval
Interval in seconds to wait after processing a job (when queue is busy)
public
float
$job_interval
= 1.0
$poll_interval
Interval in seconds between polling the DB for new jobs (when queue has been empty)
public
float
$poll_interval
= 1.0
$priority
A default priority.
public
int
$priority
= 100
Smaller numbers are executed first.
Overriden by push($job, ['priority' => ...]).
$timeout
A default timeout.
public
int
$timeout
= 300
Overriden by push($job, ['timeout' => ...]);
Methods
pop()
Get the next job from the queue.
public
pop([int $timeout = 0 ]) : JobInterface|null
Parameters
- $timeout : int = 0
-
wait for a job, in seconds
- negative: return immediately
- zero: block indefinitely
- positive: wait for the given number of seconds
Tags
Return values
JobInterface|null —the next job in the queue, otherwise null if empty
push()
Push a job onto the queue.
public
push(JobInterface $job[, array<string|int, mixed> $options = [] ]) : string
Parameters
- $job : JobInterface
- $options : array<string|int, mixed> = []
Tags
Return values
string —an unique identifier for the job within the queue
update()
public
update(iterable<string|int, mixed> $config) : void
Parameters
- $config : iterable<string|int, mixed>
executeQueue()
Run the queue immediately.
protected
executeQueue() : void
Tags
insertJob()
Insert a job into the database.
protected
insertJob(JobInterface $job[, array<string|int, mixed> $options = [] ]) : int
Parameters
- $job : JobInterface
- $options : array<string|int, mixed> = []