Neuron-PHP

QueueManager
in package

Queue manager facade for job queue operations.

Provides a unified interface for dispatching jobs, managing workers, and handling failed jobs. Manages queue driver instantiation and configuration.

Table of Contents

Properties

$_backoff  : int
$_config  : array<string|int, mixed>
$_driver  : IQueue
$_maxAttempts  : int
$_retryAfter  : int

Methods

__construct()  : mixed
clear()  : int
Clear all jobs from queue
clearFailedJobs()  : int
Clear all failed jobs
dispatch()  : string
Dispatch a job to the queue
dispatchNow()  : mixed
Dispatch a job for immediate execution (bypasses queue)
forgetFailedJob()  : bool
Forget (delete) a failed job
getConfig()  : array<string|int, mixed>
Get configuration
getDriver()  : IQueue
Get the queue driver instance
getFailedJobs()  : array<string|int, mixed>
Get all failed jobs
processNextJob()  : bool
Process the next job from the queue
retryAllFailedJobs()  : int
Retry all failed jobs
retryFailedJob()  : bool
Retry a failed job
size()  : int
Get queue size
calculateBackoff()  : int
Calculate backoff delay for retry
createDriver()  : IQueue
Create queue driver instance
getDefaultConfig()  : array<string|int, mixed>
Get default configuration
handleFailedJob()  : void
Handle a failed job
loadConfig()  : array<string|int, mixed>
Load configuration from settings source

Properties

Methods

__construct()

public __construct([ISettingSource|null $settings = null ][, array<string|int, mixed>|null $config = null ]) : mixed
Parameters
$settings : ISettingSource|null = null

Settings source for configuration

$config : array<string|int, mixed>|null = null

Direct configuration array (overrides settings)

clear()

Clear all jobs from queue

public clear([string|null $queue = null ]) : int
Parameters
$queue : string|null = null

Queue name (null = default)

Return values
int

Number of jobs cleared

clearFailedJobs()

Clear all failed jobs

public clearFailedJobs() : int
Return values
int

Number of failed jobs cleared

dispatch()

Dispatch a job to the queue

public dispatch(IJob $job[, array<string|int, mixed> $args = [] ][, string|null $queue = null ][, int $delay = 0 ]) : string
Parameters
$job : IJob

Job instance

$args : array<string|int, mixed> = []

Arguments for the job

$queue : string|null = null

Queue name (null = default)

$delay : int = 0

Delay in seconds before job is available

Return values
string

Job ID

dispatchNow()

Dispatch a job for immediate execution (bypasses queue)

public dispatchNow(IJob $job[, array<string|int, mixed> $args = [] ]) : mixed
Parameters
$job : IJob

Job instance

$args : array<string|int, mixed> = []

Arguments for the job

Return values
mixed

Job result

forgetFailedJob()

Forget (delete) a failed job

public forgetFailedJob(string $id) : bool
Parameters
$id : string

Failed job ID

Return values
bool

True if job was deleted, false if not found

getConfig()

Get configuration

public getConfig() : array<string|int, mixed>
Return values
array<string|int, mixed>

getFailedJobs()

Get all failed jobs

public getFailedJobs() : array<string|int, mixed>
Return values
array<string|int, mixed>

processNextJob()

Process the next job from the queue

public processNextJob([string|null $queue = null ]) : bool
Parameters
$queue : string|null = null

Queue name (null = default)

Return values
bool

True if a job was processed, false if queue was empty

retryAllFailedJobs()

Retry all failed jobs

public retryAllFailedJobs() : int
Return values
int

Number of jobs retried

retryFailedJob()

Retry a failed job

public retryFailedJob(string $id) : bool
Parameters
$id : string

Failed job ID

Return values
bool

True if job was retried, false if not found

size()

Get queue size

public size([string|null $queue = null ]) : int
Parameters
$queue : string|null = null

Queue name (null = default)

Return values
int

Number of jobs in queue

calculateBackoff()

Calculate backoff delay for retry

private calculateBackoff(int $attempts) : int
Parameters
$attempts : int

Number of attempts made

Return values
int

Delay in seconds

createDriver()

Create queue driver instance

private createDriver(array<string|int, mixed> $config) : IQueue
Parameters
$config : array<string|int, mixed>
Return values
IQueue

getDefaultConfig()

Get default configuration

private getDefaultConfig() : array<string|int, mixed>
Return values
array<string|int, mixed>

handleFailedJob()

Handle a failed job

private handleFailedJob(QueuedJob $job, Throwable $exception) : void
Parameters
$job : QueuedJob
$exception : Throwable

loadConfig()

Load configuration from settings source

private loadConfig(ISettingSource|null $settings) : array<string|int, mixed>
Parameters
$settings : ISettingSource|null
Return values
array<string|int, mixed>

        
On this page

Search results