Neuron-PHP

QueuedJob
in package

Represents a job in the queue with metadata.

This class wraps an IJob instance along with queue-specific metadata such as attempts, timestamps, and queue name.

Table of Contents

Properties

$_arguments  : array<string|int, mixed>
$_attempts  : int
$_availableAt  : int
$_createdAt  : int
$_id  : string
$_jobClass  : string
$_queue  : string
$_rawPayload  : string|null
$_reservedAt  : int|null

Methods

__construct()  : mixed
fromJob()  : self
Create a QueuedJob from an IJob instance
fromPayload()  : self
Create a QueuedJob from serialized payload
getArguments()  : array<string|int, mixed>
getAttempts()  : int
getAvailableAt()  : int
getCreatedAt()  : int
getId()  : string
getJob()  : IJob
Get the job instance
getJobClass()  : string
getPayload()  : string
Get the serialized payload
getQueue()  : string
getReservedAt()  : int|null
incrementAttempts()  : void
Increment the attempts counter
isAvailable()  : bool
Check if job is available for processing
isReserved()  : bool
Check if job has been reserved
markAsReserved()  : void
Mark job as reserved
setAvailableAt()  : void
setReservedAt()  : void
generateId()  : string
Generate a unique job ID

Properties

$_arguments

private array<string|int, mixed> $_arguments

$_rawPayload

private string|null $_rawPayload = null

Methods

__construct()

public __construct(string $id, string $queue, string $jobClass[, array<string|int, mixed> $arguments = [] ][, int $attempts = 0 ][, int|null $reservedAt = null ][, int $availableAt = 0 ][, int $createdAt = 0 ]) : mixed
Parameters
$id : string

Unique job ID

$queue : string

Queue name

$jobClass : string

Fully qualified job class name

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

Arguments to pass to the job

$attempts : int = 0

Number of attempts made

$reservedAt : int|null = null

Timestamp when job was reserved (null if not reserved)

$availableAt : int = 0

Timestamp when job becomes available

$createdAt : int = 0

Timestamp when job was created

fromJob()

Create a QueuedJob from an IJob instance

public static fromJob(IJob $job[, array<string|int, mixed> $arguments = [] ][, string $queue = 'default' ][, int $delay = 0 ]) : self
Parameters
$job : IJob

Job instance

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

Arguments for the job

$queue : string = 'default'

Queue name

$delay : int = 0

Delay in seconds

Return values
self

fromPayload()

Create a QueuedJob from serialized payload

public static fromPayload(string $id, string $queue, string $payload[, int $attempts = 0 ][, int|null $reservedAt = null ][, int $availableAt = 0 ][, int $createdAt = 0 ]) : self
Parameters
$id : string

Job ID

$queue : string

Queue name

$payload : string

Serialized JSON payload

$attempts : int = 0

Number of attempts

$reservedAt : int|null = null

Reserved timestamp

$availableAt : int = 0

Available timestamp

$createdAt : int = 0

Created timestamp

Return values
self

getArguments()

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

getAttempts()

public getAttempts() : int
Return values
int

getAvailableAt()

public getAvailableAt() : int
Return values
int

getCreatedAt()

public getCreatedAt() : int
Return values
int

getId()

public getId() : string
Return values
string

getJob()

Get the job instance

public getJob() : IJob
Tags
throws
RuntimeException

If job class doesn't exist or doesn't implement IJob

Return values
IJob

getJobClass()

public getJobClass() : string
Return values
string

getPayload()

Get the serialized payload

public getPayload() : string
Return values
string

JSON encoded payload

getQueue()

public getQueue() : string
Return values
string

getReservedAt()

public getReservedAt() : int|null
Return values
int|null

incrementAttempts()

Increment the attempts counter

public incrementAttempts() : void

isAvailable()

Check if job is available for processing

public isAvailable() : bool
Return values
bool

isReserved()

Check if job has been reserved

public isReserved() : bool
Return values
bool

markAsReserved()

Mark job as reserved

public markAsReserved() : void

setAvailableAt()

public setAvailableAt(int $timestamp) : void
Parameters
$timestamp : int

setReservedAt()

public setReservedAt(int|null $timestamp) : void
Parameters
$timestamp : int|null

generateId()

Generate a unique job ID

private static generateId() : string
Return values
string

        
On this page

Search results