Worker
class Worker (View source)
Properties
protected QueueManager | $manager | The queue manager instance. |
|
protected FailedJobProviderInterface | $failer | The failed job provider implementation. |
|
protected Dispatcher | $events | The event dispatcher instance. |
|
protected Repository | $cache | The cache repository implementation. |
|
protected Handler | $exceptions | The exception handler instance. |
Methods
Create a new queue worker.
Listen to the given queue in a loop.
Run the next job for the daemon worker.
Determine if the daemon should process on this iteration.
Listen to the given queue.
Determine if the memory limit has been exceeded.
Stop listening and bail out of the script.
Sleep the script for a given number of seconds.
Get the last queue restart timestamp, or null.
Determine if the queue worker should restart.
Get the queue manager instance.
Details
void
__construct(QueueManager $manager, FailedJobProviderInterface $failer = null, Dispatcher $events = null)
Create a new queue worker.
array
daemon(string $connectionName, string $queue = null, int $delay = 0, int $memory = 128, int $sleep = 3, int $maxTries = 0)
Listen to the given queue in a loop.
protected void
runNextJobForDaemon(string $connectionName, string $queue, int $delay, int $sleep, int $maxTries)
Run the next job for the daemon worker.
protected bool
daemonShouldRun()
Determine if the daemon should process on this iteration.
array
pop(string $connectionName, string $queue = null, int $delay = 0, int $sleep = 3, int $maxTries = 0)
Listen to the given queue.
protected Job|null
getNextJob(Queue $connection, string $queue)
Get the next job from the queue connection.
void
process(string $connection, Job $job, int $maxTries = 0, int $delay = 0)
Process a given job from the queue.
protected array
logFailedJob(string $connection, Job $job)
Log a failed job into storage.
protected void
raiseFailedJobEvent(string $connection, Job $job)
Raise the failed queue job event.
bool
memoryExceeded(int $memoryLimit)
Determine if the memory limit has been exceeded.
void
stop()
Stop listening and bail out of the script.
void
sleep(int $seconds)
Sleep the script for a given number of seconds.
protected int|null
getTimestampOfLastQueueRestart()
Get the last queue restart timestamp, or null.
protected bool
queueShouldRestart(int|null $lastRestart)
Determine if the queue worker should restart.
void
setDaemonExceptionHandler(Handler $handler)
Set the exception handler to use in Daemon mode.
void
setCache(Repository $cache)
Set the cache repository implementation.
QueueManager
getManager()
Get the queue manager instance.
void
setManager(QueueManager $manager)
Set the queue manager instance.