Class craft\queue\Queue
- Inheritance
- craft\queue\Queue ยป yii\queue\cli\Queue
- Implements
- craft\queue\QueueInterface
- Available since version
- 3.0
- Source Code
- https://github.com/craftcms/cms/blob/master/src/queue/Queue.php
Craft Queue
Property | Type | Description | Defined By |
---|---|---|---|
$commandClass |
string | Command class name | craft\queue\Queue |
$mutexTimeout |
integer | Timeout | craft\queue\Queue |
Method | Description | Defined By |
---|---|---|
getHasReservedJobs() |
Returns whether there are any reserved jobs | craft\queue\Queue |
getHasWaitingJobs() |
Returns whether there are any waiting jobs | craft\queue\Queue |
getJobInfo() |
Returns info about the jobs in the queue. | craft\queue\Queue |
getTotalDelayed() |
Returns the total number of delayed jobs | craft\queue\Queue |
getTotalFailed() |
Returns the total number of failed jobs | craft\queue\Queue |
getTotalReserved() |
Returns the total number of reserved jobs | craft\queue\Queue |
getTotalWaiting() |
Returns the total number of waiting jobs | craft\queue\Queue |
handleError() |
craft\queue\Queue | |
handleResponse() |
Figure out how to initiate a new worker. | craft\queue\Queue |
init() |
craft\queue\Queue | |
isFailed() |
craft\queue\Queue | |
listen() |
Listens to the queue and runs new jobs. | craft\queue\Queue |
push() |
craft\queue\Queue | |
release() |
Releases a job from the queue. | craft\queue\Queue |
retry() |
Re-adds a failed job to the queue. | craft\queue\Queue |
run() |
Runs all the queued-up jobs | craft\queue\Queue |
setProgress() |
Sets the progress for the currently reserved job. | craft\queue\Queue |
status() |
craft\queue\Queue |
Method | Description | Defined By |
---|---|---|
pushMessage() |
craft\queue\Queue | |
reserve() |
craft\queue\Queue |
Constant | Value | Description | Defined By |
---|---|---|---|
STATUS_FAILED |
4 | craft\queue\Queue |
Property Details
$commandClass
public property
#
Command class name
public string $commandClass = \craft\queue\Command::class
$mutexTimeout
public property
#
Timeout
public integer $mutexTimeout = 3
Method Details
getHasReservedJobs()
public method
#
Returns whether there are any reserved jobs
public boolean getHasReservedJobs ( )
getHasWaitingJobs()
public method
#
Returns whether there are any waiting jobs
public boolean getHasWaitingJobs ( )
getJobInfo()
public method
#
Returns info about the jobs in the queue.
The response array should have sub-arrays with the following keys:
- 'id': The job ID
- 'status': The job status (1 = waiting, 2 = reserved, 3 = done, 4 = failed)
- 'progress': The job progress (0-100)
- 'description': The job description
- 'error': The error message (if the job failed)
public array getJobInfo ( \craft\queue\int $limit = null )
$limit |
integer, null |
getTotalDelayed()
public method
#
Returns the total number of delayed jobs
public integer getTotalDelayed ( )
getTotalFailed()
public method
#
Returns the total number of failed jobs
public integer getTotalFailed ( )
getTotalReserved()
public method
#
Returns the total number of reserved jobs
public integer getTotalReserved ( )
getTotalWaiting()
public method
#
Returns the total number of waiting jobs
public integer getTotalWaiting ( )
handleError()
public method
#
public void handleError ( $id, $job, $ttr, $attempt, $error )
$id |
||
$job |
||
$ttr |
||
$attempt |
||
$error |
handleResponse()
public method
#
Figure out how to initiate a new worker.
public void handleResponse ( )
init()
public method
#
public void init ( )
isFailed()
public method
#
public boolean isFailed ( \craft\queue\string $id )
$id |
string | Of a job message |
listen()
public method
#
Listens to the queue and runs new jobs.
public void listen ( \craft\queue\int $delay )
$delay |
integer | Number of seconds for waiting new job. |
push()
public method
#
public void push ( $job )
$job |
pushMessage()
protected method
#
protected void pushMessage ( $message, $ttr, $delay, $priority )
$message |
||
$ttr |
||
$delay |
||
$priority |
release()
public method
#
Releases a job from the queue.
public void release ( \craft\queue\string $id )
$id |
string |
reserve()
protected method
#
protected array, null reserve ( )
return | array, null | The payload, or null if there aren't any jobs to reserve |
---|---|---|
throws | yii\base\Exception | in case it hasn't waited the lock |
retry()
public method
#
Re-adds a failed job to the queue.
public void retry ( \craft\queue\string $id )
$id |
string |
run()
public method
#
Runs all the queued-up jobs
public void run ( )
setProgress()
public method
#
Sets the progress for the currently reserved job.
public void setProgress ( \craft\queue\int $progress )
$progress |
integer | The job progress (1-100) |
status()
public method
#
public void status ( $id )
$id |