PHP Класс Illuminate\Queue\Worker

Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$cache Illuminate\Contracts\Cache\Repository The cache repository implementation.
$events Illuminate\Contracts\Events\Dispatcher The event dispatcher instance.
$exceptions Illuminate\Foundation\Exceptions\Handler The exception handler instance.
$manager Illuminate\Queue\QueueManager The queue manager instance.

Открытые методы

Метод Описание
__construct ( Illuminate\Queue\QueueManager $manager, Illuminate\Contracts\Events\Dispatcher $events, Illuminate\Contracts\Debug\ExceptionHandler $exceptions ) : void Create a new queue worker.
daemon ( string $connectionName, string $queue, WorkerOptions $options ) : void Listen to the given queue in a loop.
getManager ( ) : Illuminate\Queue\QueueManager Get the queue manager instance.
memoryExceeded ( integer $memoryLimit ) : boolean Determine if the memory limit has been exceeded.
process ( string $connectionName, Illuminate\Contracts\Queue\Job $job, WorkerOptions $options ) : void Process a given job from the queue.
runNextJob ( string $connectionName, string $queue, WorkerOptions $options ) : void Process the next job on the queue.
setCache ( Illuminate\Contracts\Cache\Repository $cache ) : void Set the cache repository implementation.
setManager ( Illuminate\Queue\QueueManager $manager ) : void Set the queue manager instance.
sleep ( integer $seconds ) : void Sleep the script for a given number of seconds.
stop ( ) : void Stop listening and bail out of the script.

Защищенные методы

Метод Описание
daemonShouldRun ( WorkerOptions $options ) : boolean Determine if the daemon should process on this iteration.
failJob ( string $connectionName, Illuminate\Contracts\Queue\Job $job, Exception $e ) : void Mark the given job as failed and raise the relevant event.
getNextJob ( Illuminate\Contracts\Queue\Queue $connection, string $queue ) : Illuminate\Contracts\Queue\Job | null Get the next job from the queue connection.
getTimestampOfLastQueueRestart ( ) : integer | null Get the last queue restart timestamp, or null.
handleJobException ( string $connectionName, Illuminate\Contracts\Queue\Job $job, WorkerOptions $options, Exception $e ) : void Handle an exception that occurred while the job was running.
markJobAsFailedIfAlreadyExceedsMaxAttempts ( string $connectionName, Illuminate\Contracts\Queue\Job $job, integer $maxTries ) : void Mark the given job as failed if it has exceeded the maximum allowed attempts.
markJobAsFailedIfHasExceededMaxAttempts ( string $connectionName, Illuminate\Contracts\Queue\Job $job, integer $maxTries, Exception $e ) : void Mark the given job as failed if it has exceeded the maximum allowed attempts.
queueShouldRestart ( integer | null $lastRestart ) : boolean Determine if the queue worker should restart.
raiseAfterJobEvent ( string $connectionName, Illuminate\Contracts\Queue\Job $job ) : void Raise the after queue job event.
raiseBeforeJobEvent ( string $connectionName, Illuminate\Contracts\Queue\Job $job ) : void Raise the before queue job event.
raiseExceptionOccurredJobEvent ( string $connectionName, Illuminate\Contracts\Queue\Job $job, Exception $e ) : void Raise the exception occurred queue job event.
raiseFailedJobEvent ( string $connectionName, Illuminate\Contracts\Queue\Job $job, Exception $e ) : void Raise the failed queue job event.
registerTimeoutHandler ( Illuminate\Contracts\Queue\Job | null $job, WorkerOptions $options ) : void Register the worker timeout handler (PHP 7.1+).
runJob ( Illuminate\Contracts\Queue\Job $job, string $connectionName, WorkerOptions $options ) : void Process the given job.

Описание методов

__construct() публичный метод

Create a new queue worker.
public __construct ( Illuminate\Queue\QueueManager $manager, Illuminate\Contracts\Events\Dispatcher $events, Illuminate\Contracts\Debug\ExceptionHandler $exceptions ) : void
$manager Illuminate\Queue\QueueManager
$events Illuminate\Contracts\Events\Dispatcher
$exceptions Illuminate\Contracts\Debug\ExceptionHandler
Результат void

daemon() публичный метод

Listen to the given queue in a loop.
public daemon ( string $connectionName, string $queue, WorkerOptions $options ) : void
$connectionName string
$queue string
$options WorkerOptions
Результат void

daemonShouldRun() защищенный метод

Determine if the daemon should process on this iteration.
protected daemonShouldRun ( WorkerOptions $options ) : boolean
$options WorkerOptions
Результат boolean

failJob() защищенный метод

Mark the given job as failed and raise the relevant event.
protected failJob ( string $connectionName, Illuminate\Contracts\Queue\Job $job, Exception $e ) : void
$connectionName string
$job Illuminate\Contracts\Queue\Job
$e Exception
Результат void

getManager() публичный метод

Get the queue manager instance.
public getManager ( ) : Illuminate\Queue\QueueManager
Результат Illuminate\Queue\QueueManager

getNextJob() защищенный метод

Get the next job from the queue connection.
protected getNextJob ( Illuminate\Contracts\Queue\Queue $connection, string $queue ) : Illuminate\Contracts\Queue\Job | null
$connection Illuminate\Contracts\Queue\Queue
$queue string
Результат Illuminate\Contracts\Queue\Job | null

getTimestampOfLastQueueRestart() защищенный метод

Get the last queue restart timestamp, or null.
protected getTimestampOfLastQueueRestart ( ) : integer | null
Результат integer | null

handleJobException() защищенный метод

Handle an exception that occurred while the job was running.
protected handleJobException ( string $connectionName, Illuminate\Contracts\Queue\Job $job, WorkerOptions $options, Exception $e ) : void
$connectionName string
$job Illuminate\Contracts\Queue\Job
$options WorkerOptions
$e Exception
Результат void

markJobAsFailedIfAlreadyExceedsMaxAttempts() защищенный метод

This will likely be because the job previously exceeded a timeout.
protected markJobAsFailedIfAlreadyExceedsMaxAttempts ( string $connectionName, Illuminate\Contracts\Queue\Job $job, integer $maxTries ) : void
$connectionName string
$job Illuminate\Contracts\Queue\Job
$maxTries integer
Результат void

markJobAsFailedIfHasExceededMaxAttempts() защищенный метод

Mark the given job as failed if it has exceeded the maximum allowed attempts.
protected markJobAsFailedIfHasExceededMaxAttempts ( string $connectionName, Illuminate\Contracts\Queue\Job $job, integer $maxTries, Exception $e ) : void
$connectionName string
$job Illuminate\Contracts\Queue\Job
$maxTries integer
$e Exception
Результат void

memoryExceeded() публичный метод

Determine if the memory limit has been exceeded.
public memoryExceeded ( integer $memoryLimit ) : boolean
$memoryLimit integer
Результат boolean

process() публичный метод

Process a given job from the queue.
public process ( string $connectionName, Illuminate\Contracts\Queue\Job $job, WorkerOptions $options ) : void
$connectionName string
$job Illuminate\Contracts\Queue\Job
$options WorkerOptions
Результат void

queueShouldRestart() защищенный метод

Determine if the queue worker should restart.
protected queueShouldRestart ( integer | null $lastRestart ) : boolean
$lastRestart integer | null
Результат boolean

raiseAfterJobEvent() защищенный метод

Raise the after queue job event.
protected raiseAfterJobEvent ( string $connectionName, Illuminate\Contracts\Queue\Job $job ) : void
$connectionName string
$job Illuminate\Contracts\Queue\Job
Результат void

raiseBeforeJobEvent() защищенный метод

Raise the before queue job event.
protected raiseBeforeJobEvent ( string $connectionName, Illuminate\Contracts\Queue\Job $job ) : void
$connectionName string
$job Illuminate\Contracts\Queue\Job
Результат void

raiseExceptionOccurredJobEvent() защищенный метод

Raise the exception occurred queue job event.
protected raiseExceptionOccurredJobEvent ( string $connectionName, Illuminate\Contracts\Queue\Job $job, Exception $e ) : void
$connectionName string
$job Illuminate\Contracts\Queue\Job
$e Exception
Результат void

raiseFailedJobEvent() защищенный метод

Raise the failed queue job event.
protected raiseFailedJobEvent ( string $connectionName, Illuminate\Contracts\Queue\Job $job, Exception $e ) : void
$connectionName string
$job Illuminate\Contracts\Queue\Job
$e Exception
Результат void

registerTimeoutHandler() защищенный метод

Register the worker timeout handler (PHP 7.1+).
protected registerTimeoutHandler ( Illuminate\Contracts\Queue\Job | null $job, WorkerOptions $options ) : void
$job Illuminate\Contracts\Queue\Job | null
$options WorkerOptions
Результат void

runJob() защищенный метод

Process the given job.
protected runJob ( Illuminate\Contracts\Queue\Job $job, string $connectionName, WorkerOptions $options ) : void
$job Illuminate\Contracts\Queue\Job
$connectionName string
$options WorkerOptions
Результат void

runNextJob() публичный метод

Process the next job on the queue.
public runNextJob ( string $connectionName, string $queue, WorkerOptions $options ) : void
$connectionName string
$queue string
$options WorkerOptions
Результат void

setCache() публичный метод

Set the cache repository implementation.
public setCache ( Illuminate\Contracts\Cache\Repository $cache ) : void
$cache Illuminate\Contracts\Cache\Repository
Результат void

setManager() публичный метод

Set the queue manager instance.
public setManager ( Illuminate\Queue\QueueManager $manager ) : void
$manager Illuminate\Queue\QueueManager
Результат void

sleep() публичный метод

Sleep the script for a given number of seconds.
public sleep ( integer $seconds ) : void
$seconds integer
Результат void

stop() публичный метод

Stop listening and bail out of the script.
public stop ( ) : void
Результат void

Описание свойств

$cache защищенное свойство

The cache repository implementation.
protected Repository,Illuminate\Contracts\Cache $cache
Результат Illuminate\Contracts\Cache\Repository

$events защищенное свойство

The event dispatcher instance.
protected Dispatcher,Illuminate\Contracts\Events $events
Результат Illuminate\Contracts\Events\Dispatcher

$exceptions защищенное свойство

The exception handler instance.
protected Handler,Illuminate\Foundation\Exceptions $exceptions
Результат Illuminate\Foundation\Exceptions\Handler

$manager защищенное свойство

The queue manager instance.
protected QueueManager,Illuminate\Queue $manager
Результат Illuminate\Queue\QueueManager