class QueueManager implements Factory, Monitor mixin Queue (View source)

Traits

Properties

protected Application $app

The application instance.

protected array $connections

The array of resolved queue connections.

protected array $connectors

The array of resolved queue connectors.

Methods

int
secondsUntil(DateTimeInterface|DateInterval|int $delay)

Get the number of seconds until the given DateTime.

int
availableAt(DateTimeInterface|DateInterval|int $delay = 0)

Get the "available at" UNIX timestamp.

parseDateInterval(DateTimeInterface|DateInterval|int $delay)

If the given value is an interval, convert it to a DateTime instance.

int
currentTime()

Get the current system time as a UNIX timestamp.

string
runTimeForHumans(float $startTime, float|null $endTime = null)

Given a start time, format the total run time for human readability.

string|null
resolveConnectionFromQueueRoute(object $queueable)

Resolve the default connection name for a given queueable instance.

string|null
resolveQueueFromQueueRoute(object $queueable)

Resolve the default queue name for a given queueable instance.

queueRoutes()

Get the queue routes manager instance.

__construct(Application $app)

Create a new queue manager instance.

void
before(mixed $callback)

Register an event listener for the before job event.

void
after(mixed $callback)

Register an event listener for the after job event.

void
exceptionOccurred(mixed $callback)

Register an event listener for the exception occurred job event.

void
looping(mixed $callback)

Register an event listener for the daemon queue loop.

void
failing(mixed $callback)

Register an event listener for the failed job event.

void
starting(mixed $callback)

Register an event listener for the daemon queue starting.

void
stopping(mixed $callback)

Register an event listener for the daemon queue stopping.

void
whenJobRunsLongerThan(DateTimeInterface|CarbonInterval|float|int $threshold, callable $handler)

Register a callback to be invoked when a job runs for longer than a given amount of time.

void
route(array|string $class, UnitEnum|string|null $queue = null, UnitEnum|string|null $connection = null)

Set the queue route for the given class.

void
forward(array|string|UnitEnum $queue, UnitEnum|string|null $to = null, UnitEnum|string|null $connection = null)

Forward the given queue to another queue and/or connection.

bool
connected(UnitEnum|string|null $name = null)

Determine if the driver is connected.

connection(UnitEnum|string|null $name = null)

Resolve a queue connection instance.

resolve(string $name)

Resolve a queue connection.

getConnector(string $driver)

Get the connector for a given driver.

void
pause(UnitEnum|string $queue, UnitEnum|string|null $connection = null)

Pause a queue by its name and connection.

void
pauseFor(UnitEnum|string $queue, DateTimeInterface|DateInterval|int $ttl, UnitEnum|string|null $connection = null)

Pause a queue by its name and connection for a given amount of time.

void
pauseAll()

Pause job processing for all queues on all connections.

void
resume(UnitEnum|string $queue, UnitEnum|string|null $connection = null)

Resume a paused queue by its connection and name.

void
resumeAll()

Resume job processing for all queues on all connections.

bool
isPaused(UnitEnum|string $queue, UnitEnum|string|null $connection = null)

Determine if a queue is paused.

array
getPausedQueues(array $queues, string|null $connection = null)

Determine which of the given queues are currently paused.

void
withoutInterruptionPolling()

Indicate that queue workers should not poll for restart or pause signals.

void
extend(string $driver, Closure $resolver)

Add a queue connection resolver.

void
addConnector(string $driver, Closure $resolver)

Add a queue connection resolver.

array|null
getConfig(string $name)

Get the queue connection configuration.

string
getDefaultDriver()

Get the name of the default queue connection.

void
setDefaultDriver(UnitEnum|string $name)

Set the name of the default queue connection.

string
getName(string|null $connection = null)

Get the full name for the given connection.

getApplication()

Get the application instance used by the manager.

$this
setApplication(Application $app)

Set the application instance used by the manager.

void
createPayloadUsing(callable|null $callback)

Register a callback to be executed when creating job payloads.

mixed
__call(string $method, array $parameters)

Dynamically pass calls to the default connection.

Details

protected int secondsUntil(DateTimeInterface|DateInterval|int $delay)

Get the number of seconds until the given DateTime.

Parameters

DateTimeInterface|DateInterval|int $delay

Return Value

int

protected int availableAt(DateTimeInterface|DateInterval|int $delay = 0)

Get the "available at" UNIX timestamp.

Parameters

DateTimeInterface|DateInterval|int $delay

Return Value

int

protected DateTimeInterface|int parseDateInterval(DateTimeInterface|DateInterval|int $delay)

If the given value is an interval, convert it to a DateTime instance.

Parameters

DateTimeInterface|DateInterval|int $delay

Return Value

DateTimeInterface|int

protected int currentTime()

Get the current system time as a UNIX timestamp.

Return Value

int

protected string runTimeForHumans(float $startTime, float|null $endTime = null)

Given a start time, format the total run time for human readability.

Parameters

float $startTime
float|null $endTime

Return Value

string

string|null resolveConnectionFromQueueRoute(object $queueable)

Resolve the default connection name for a given queueable instance.

Parameters

object $queueable

Return Value

string|null

string|null resolveQueueFromQueueRoute(object $queueable)

Resolve the default queue name for a given queueable instance.

Parameters

object $queueable

Return Value

string|null

protected QueueRoutes queueRoutes()

Get the queue routes manager instance.

Return Value

QueueRoutes

__construct(Application $app)

Create a new queue manager instance.

Parameters

Application $app

void before(mixed $callback)

Register an event listener for the before job event.

Parameters

mixed $callback

Return Value

void

void after(mixed $callback)

Register an event listener for the after job event.

Parameters

mixed $callback

Return Value

void

void exceptionOccurred(mixed $callback)

Register an event listener for the exception occurred job event.

Parameters

mixed $callback

Return Value

void

void looping(mixed $callback)

Register an event listener for the daemon queue loop.

Parameters

mixed $callback

Return Value

void

void failing(mixed $callback)

Register an event listener for the failed job event.

Parameters

mixed $callback

Return Value

void

void starting(mixed $callback)

Register an event listener for the daemon queue starting.

Parameters

mixed $callback

Return Value

void

void stopping(mixed $callback)

Register an event listener for the daemon queue stopping.

Parameters

mixed $callback

Return Value

void

void whenJobRunsLongerThan(DateTimeInterface|CarbonInterval|float|int $threshold, callable $handler)

Register a callback to be invoked when a job runs for longer than a given amount of time.

Parameters

DateTimeInterface|CarbonInterval|float|int $threshold
callable $handler

Return Value

void

void route(array|string $class, UnitEnum|string|null $queue = null, UnitEnum|string|null $connection = null)

Set the queue route for the given class.

Parameters

array|string $class
UnitEnum|string|null $queue
UnitEnum|string|null $connection

Return Value

void

void forward(array|string|UnitEnum $queue, UnitEnum|string|null $to = null, UnitEnum|string|null $connection = null)

Forward the given queue to another queue and/or connection.

Parameters

array|string|UnitEnum $queue
UnitEnum|string|null $to
UnitEnum|string|null $connection

Return Value

void

bool connected(UnitEnum|string|null $name = null)

Determine if the driver is connected.

Parameters

UnitEnum|string|null $name

Return Value

bool

Queue connection(UnitEnum|string|null $name = null)

Resolve a queue connection instance.

Parameters

UnitEnum|string|null $name

Return Value

Queue

protected Queue resolve(string $name)

Resolve a queue connection.

Parameters

string $name

Return Value

Queue

Exceptions

InvalidArgumentException

protected ConnectorInterface getConnector(string $driver)

Get the connector for a given driver.

Parameters

string $driver

Return Value

ConnectorInterface

Exceptions

InvalidArgumentException

void pause(UnitEnum|string $queue, UnitEnum|string|null $connection = null)

Pause a queue by its name and connection.

Parameters

UnitEnum|string $queue
UnitEnum|string|null $connection

Return Value

void

void pauseFor(UnitEnum|string $queue, DateTimeInterface|DateInterval|int $ttl, UnitEnum|string|null $connection = null)

Pause a queue by its name and connection for a given amount of time.

Parameters

UnitEnum|string $queue
DateTimeInterface|DateInterval|int $ttl
UnitEnum|string|null $connection

Return Value

void

void pauseAll()

Pause job processing for all queues on all connections.

Return Value

void

void resume(UnitEnum|string $queue, UnitEnum|string|null $connection = null)

Resume a paused queue by its connection and name.

Parameters

UnitEnum|string $queue
UnitEnum|string|null $connection

Return Value

void

void resumeAll()

Resume job processing for all queues on all connections.

Queues paused individually are not affected.

Return Value

void

bool isPaused(UnitEnum|string $queue, UnitEnum|string|null $connection = null)

Determine if a queue is paused.

Parameters

UnitEnum|string $queue
UnitEnum|string|null $connection

Return Value

bool

array getPausedQueues(array $queues, string|null $connection = null)

Determine which of the given queues are currently paused.

Parameters

array $queues
string|null $connection

Return Value

array

void withoutInterruptionPolling()

Indicate that queue workers should not poll for restart or pause signals.

This prevents the workers from hitting the application cache to determine if they need to pause or restart.

Return Value

void

void extend(string $driver, Closure $resolver)

Add a queue connection resolver.

Parameters

string $driver
Closure $resolver

Return Value

void

void addConnector(string $driver, Closure $resolver)

Add a queue connection resolver.

Parameters

string $driver
Closure $resolver

Return Value

void

protected array|null getConfig(string $name)

Get the queue connection configuration.

Parameters

string $name

Return Value

array|null

string getDefaultDriver()

Get the name of the default queue connection.

Return Value

string

void setDefaultDriver(UnitEnum|string $name)

Set the name of the default queue connection.

Parameters

UnitEnum|string $name

Return Value

void

string getName(string|null $connection = null)

Get the full name for the given connection.

Parameters

string|null $connection

Return Value

string

Application getApplication()

Get the application instance used by the manager.

Return Value

Application

$this setApplication(Application $app)

Set the application instance used by the manager.

Parameters

Application $app

Return Value

$this

void createPayloadUsing(callable|null $callback)

Register a callback to be executed when creating job payloads.

Parameters

callable|null $callback

Return Value

void

mixed __call(string $method, array $parameters)

Dynamically pass calls to the default connection.

Parameters

string $method
array $parameters

Return Value

mixed