class QueueManager implements Factory, Monitor mixin Queue

Traits

Properties

protected Closure> $releaseCallbacks from  HasPoolProxy
protected array $connections

The array of resolved queue connections.

protected array $connectors

The array of resolved queue connectors.

protected array $poolables

The array of drivers which will be wrapped as pool proxies.

Methods

mixed
createPoolProxy(string $driver, Closure $resolver, PoolDefinition $definition, string $proxyClass)

Create a pool proxy for an immutable definition.

poolDefinition(string $resource, array $poolConfig, array $fingerprintSource)

Build a namespaced pool definition for a pooled resource.

poolFactory()

Get the shared object-pool factory.

setReleaseCallback(string $driver, Closure $callback)

Set the release callback for a pooled driver.

Closure|null
getReleaseCallback(string $driver)

Get the release callback for a pooled driver.

addPoolable(string $driver)

Add a driver to the poolable-driver list.

removePoolable(string $driver)

Remove a driver from the poolable-driver list.

array
getPoolables()

Get the poolable-driver list.

setPoolables(array $poolables)

Set the poolable-driver list.

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(Container $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
route(array|string $class, UnitEnum|string|null $queue = null, UnitEnum|string|null $connection = null)

Register the default queue route for a given class.

void
pause(string $connection, string $queue)

Pause a queue by its connection and name.

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

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

void
resume(string $connection, string $queue)

Resume a paused queue by its connection and name.

bool
isPaused(string $connection, string $queue)

Determine if a queue is paused.

array
getPausedQueues(string $connection, array $queues)

Determine which of the given queues are currently paused.

void
withoutInterruptionPolling()

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

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
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.

void
purge(string|null $name = null)

Disconnect a queue connection and close its shared resource pool.

getApplication()

Get the application instance used by the manager.

setApplication(Container $app)

Set the application instance used by the manager.

__call(string $method, array $parameters)

Dynamically pass calls to the default connection.

Details

in HasPoolProxy at line 24
protected mixed createPoolProxy(string $driver, Closure $resolver, PoolDefinition $definition, string $proxyClass)

Create a pool proxy for an immutable definition.

Parameters

string $driver
Closure $resolver
PoolDefinition $definition
string $proxyClass

Return Value

mixed

in HasPoolProxy at line 45
protected PoolDefinition poolDefinition(string $resource, array $poolConfig, array $fingerprintSource)

Build a namespaced pool definition for a pooled resource.

Parameters

string $resource
array $poolConfig
array $fingerprintSource

Return Value

PoolDefinition

at line 362
protected Factory poolFactory()

Get the shared object-pool factory.

Return Value

Factory

in HasPoolProxy at line 71
HasPoolProxy setReleaseCallback(string $driver, Closure $callback)

Set the release callback for a pooled driver.

Boot-only. The callback persists on the manager for the worker lifetime and is captured by every subsequently created proxy for the driver.

Parameters

string $driver
Closure $callback

Return Value

HasPoolProxy

in HasPoolProxy at line 81
Closure|null getReleaseCallback(string $driver)

Get the release callback for a pooled driver.

Parameters

string $driver

Return Value

Closure|null

in HasPoolProxy at line 93
HasPoolProxy addPoolable(string $driver)

Add a driver to the poolable-driver list.

Boot-only. The list persists on the manager for the worker lifetime and is consulted on subsequent driver creation. Per-request use races across coroutines and does not affect already-cached drivers.

Parameters

string $driver

Return Value

HasPoolProxy

in HasPoolProxy at line 109
HasPoolProxy removePoolable(string $driver)

Remove a driver from the poolable-driver list.

Boot-only. The list persists on the manager for the worker lifetime and is consulted on subsequent driver creation. Per-request use races across coroutines and does not affect already-cached drivers.

Parameters

string $driver

Return Value

HasPoolProxy

in HasPoolProxy at line 126
array getPoolables()

Get the poolable-driver list.

Return Value

array

in HasPoolProxy at line 138
HasPoolProxy setPoolables(array $poolables)

Set the poolable-driver list.

Boot-only. The list persists on the manager for the worker lifetime and is consulted on subsequent driver creation. Per-request use races across coroutines and does not affect already-cached drivers.

Parameters

array $poolables

Return Value

HasPoolProxy

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

at line 50
__construct(Container $app)

Create a new queue manager instance.

Parameters

Container $app

at line 61
void before(mixed $callback)

Register an event listener for the before job event.

Boot-only. The listener persists on the singleton event dispatcher for the worker lifetime and runs for every subsequent matching queue event.

Parameters

mixed $callback

Return Value

void

at line 73
void after(mixed $callback)

Register an event listener for the after job event.

Boot-only. The listener persists on the singleton event dispatcher for the worker lifetime and runs for every subsequent matching queue event.

Parameters

mixed $callback

Return Value

void

at line 85
void exceptionOccurred(mixed $callback)

Register an event listener for the exception occurred job event.

Boot-only. The listener persists on the singleton event dispatcher for the worker lifetime and runs for every subsequent matching queue event.

Parameters

mixed $callback

Return Value

void

at line 97
void looping(mixed $callback)

Register an event listener for the daemon queue loop.

Boot-only. The listener persists on the singleton event dispatcher for the worker lifetime and runs for every subsequent matching queue event.

Parameters

mixed $callback

Return Value

void

at line 109
void failing(mixed $callback)

Register an event listener for the failed job event.

Boot-only. The listener persists on the singleton event dispatcher for the worker lifetime and runs for every subsequent matching queue event.

Parameters

mixed $callback

Return Value

void

at line 121
void starting(mixed $callback)

Register an event listener for the daemon queue starting.

Boot-only. The listener persists on the singleton event dispatcher for the worker lifetime and runs for every subsequent matching queue event.

Parameters

mixed $callback

Return Value

void

at line 133
void stopping(mixed $callback)

Register an event listener for the daemon queue stopping.

Boot-only. The listener persists on the singleton event dispatcher for the worker lifetime and runs for every subsequent matching queue event.

Parameters

mixed $callback

Return Value

void

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

Register the default queue route for a given class.

Boot-only. The route persists on the singleton QueueRoutes registry for the worker lifetime and affects every subsequent dispatch of that class.

Parameters

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

Return Value

void

at line 155
void pause(string $connection, string $queue)

Pause a queue by its connection and name.

Parameters

string $connection
string $queue

Return Value

void

at line 170
void pauseFor(string $connection, string $queue, DateInterval|DateTimeInterface|int $ttl)

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

Parameters

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

Return Value

void

at line 185
void resume(string $connection, string $queue)

Resume a paused queue by its connection and name.

Parameters

string $connection
string $queue

Return Value

void

at line 200
bool isPaused(string $connection, string $queue)

Determine if a queue is paused.

Parameters

string $connection
string $queue

Return Value

bool

at line 211
array getPausedQueues(string $connection, array $queues)

Determine which of the given queues are currently paused.

Parameters

string $connection
array $queues

Return Value

array

at line 232
void withoutInterruptionPolling()

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

Boot-only. Mutates process-global worker flags; runtime use races across coroutines and changes every concurrent worker pause or restart check.

Return Value

void

at line 241
bool connected(UnitEnum|string|null $name = null)

Determine if the driver is connected.

Parameters

UnitEnum|string|null $name

Return Value

bool

at line 257
Queue connection(UnitEnum|string|null $name = null)

Resolve a queue connection instance.

Parameters

UnitEnum|string|null $name

Return Value

Queue

at line 282
protected Queue resolve(string $name)

Resolve a queue connection.

Parameters

string $name

Return Value

Queue

Exceptions

InvalidArgumentException

at line 316
protected ConnectorInterface getConnector(string $driver)

Get the connector for a given driver.

Parameters

string $driver

Return Value

ConnectorInterface

Exceptions

InvalidArgumentException

at line 331
void extend(string $driver, Closure $resolver)

Add a queue connection resolver.

Boot-only. The resolver persists in the singleton's connectors array for the worker lifetime and applies to every subsequent connection.

Parameters

string $driver
Closure $resolver

Return Value

void

at line 342
void addConnector(string $driver, Closure $resolver)

Add a queue connection resolver.

Boot-only. The resolver persists in the singleton's connectors array for the worker lifetime and applies to every subsequent connection.

Parameters

string $driver
Closure $resolver

Return Value

void

at line 350
protected array|null getConfig(string $name)

Get the queue connection configuration.

Parameters

string $name

Return Value

array|null

at line 370
string getDefaultDriver()

Get the name of the default queue connection.

Return Value

string

at line 380
void setDefaultDriver(UnitEnum|string $name)

Set the name of the default queue connection.

Boot-only. Mutates process-global config; per-request use races across coroutines.

Parameters

UnitEnum|string $name

Return Value

void

at line 390
string getName(string|null $connection = null)

Get the full name for the given connection.

Parameters

string|null $connection

Return Value

string

at line 404
void purge(string|null $name = null)

Disconnect a queue connection and close its shared resource pool.

Boot or tests only, plus operational recovery of broken pooled resources. Other connections sharing the pool transparently acquire a fresh pool on their next operation.

Parameters

string|null $name

Return Value

void

at line 440
Container getApplication()

Get the application instance used by the manager.

Return Value

Container

at line 452
QueueManager setApplication(Container $app)

Set the application instance used by the manager.

Tests only. Swaps the container reference on the singleton and on every cached queue connection; per-request use races across coroutines and breaks every concurrent dispatch.

Parameters

Container $app

Return Value

QueueManager

at line 473
__call(string $method, array $parameters)

Dynamically pass calls to the default connection.

Parameters

string $method
array $parameters