PHP Class Illuminate\Queue\Worker

Afficher le fichier Open project: illuminate/queue Class Usage Examples

Protected Properties

Свойство Type Description
$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.

Méthodes publiques

Méthode Description
__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.

Méthodes protégées

Méthode Description
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.

Method Details

__construct() public méthode

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
Résultat void

daemon() public méthode

Listen to the given queue in a loop.
public daemon ( string $connectionName, string $queue, WorkerOptions $options ) : void
$connectionName string
$queue string
$options WorkerOptions
Résultat void

daemonShouldRun() protected méthode

Determine if the daemon should process on this iteration.
protected daemonShouldRun ( WorkerOptions $options ) : boolean
$options WorkerOptions
Résultat boolean

failJob() protected méthode

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
Résultat void

getManager() public méthode

Get the queue manager instance.
public getManager ( ) : Illuminate\Queue\QueueManager
Résultat Illuminate\Queue\QueueManager

getNextJob() protected méthode

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
Résultat Illuminate\Contracts\Queue\Job | null

getTimestampOfLastQueueRestart() protected méthode

Get the last queue restart timestamp, or null.
protected getTimestampOfLastQueueRestart ( ) : integer | null
Résultat integer | null

handleJobException() protected méthode

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
Résultat void

markJobAsFailedIfAlreadyExceedsMaxAttempts() protected méthode

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
Résultat void

markJobAsFailedIfHasExceededMaxAttempts() protected méthode

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
Résultat void

memoryExceeded() public méthode

Determine if the memory limit has been exceeded.
public memoryExceeded ( integer $memoryLimit ) : boolean
$memoryLimit integer
Résultat boolean

process() public méthode

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
Résultat void

queueShouldRestart() protected méthode

Determine if the queue worker should restart.
protected queueShouldRestart ( integer | null $lastRestart ) : boolean
$lastRestart integer | null
Résultat boolean

raiseAfterJobEvent() protected méthode

Raise the after queue job event.
protected raiseAfterJobEvent ( string $connectionName, Illuminate\Contracts\Queue\Job $job ) : void
$connectionName string
$job Illuminate\Contracts\Queue\Job
Résultat void

raiseBeforeJobEvent() protected méthode

Raise the before queue job event.
protected raiseBeforeJobEvent ( string $connectionName, Illuminate\Contracts\Queue\Job $job ) : void
$connectionName string
$job Illuminate\Contracts\Queue\Job
Résultat void

raiseExceptionOccurredJobEvent() protected méthode

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
Résultat void

raiseFailedJobEvent() protected méthode

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
Résultat void

registerTimeoutHandler() protected méthode

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
Résultat void

runJob() protected méthode

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
Résultat void

runNextJob() public méthode

Process the next job on the queue.
public runNextJob ( string $connectionName, string $queue, WorkerOptions $options ) : void
$connectionName string
$queue string
$options WorkerOptions
Résultat void

setCache() public méthode

Set the cache repository implementation.
public setCache ( Illuminate\Contracts\Cache\Repository $cache ) : void
$cache Illuminate\Contracts\Cache\Repository
Résultat void

setManager() public méthode

Set the queue manager instance.
public setManager ( Illuminate\Queue\QueueManager $manager ) : void
$manager Illuminate\Queue\QueueManager
Résultat void

sleep() public méthode

Sleep the script for a given number of seconds.
public sleep ( integer $seconds ) : void
$seconds integer
Résultat void

stop() public méthode

Stop listening and bail out of the script.
public stop ( ) : void
Résultat void

Property Details

$cache protected_oe property

The cache repository implementation.
protected Repository,Illuminate\Contracts\Cache $cache
Résultat Illuminate\Contracts\Cache\Repository

$events protected_oe property

The event dispatcher instance.
protected Dispatcher,Illuminate\Contracts\Events $events
Résultat Illuminate\Contracts\Events\Dispatcher

$exceptions protected_oe property

The exception handler instance.
protected Handler,Illuminate\Foundation\Exceptions $exceptions
Résultat Illuminate\Foundation\Exceptions\Handler

$manager protected_oe property

The queue manager instance.
protected QueueManager,Illuminate\Queue $manager
Résultat Illuminate\Queue\QueueManager