Skip to content

Value Objects ​

All are final and readonly, in Solo\JobQueue. Their dates are UTC DateTimeImmutable values.

ClaimedJob ​

One attempt, returned by claim() and renew(). The token is what acknowledges it: a job ID alone cannot.

PropertyTypeDescription
idintThe job's ID
namestringThe job's class name
payloadstringThe codec's JSON, for decode()
attemptintThis attempt's number, from 1
tokenstringThe random token of this attempt
leaseUntilDateTimeImmutableWhen this attempt's lease ends
retryPolicyRetryPolicyThe policy stored with the job
expiresAt?DateTimeImmutableThe job's deadline
php
public function withLeaseUntil(DateTimeImmutable $leaseUntil): self

A copy with another lease end; renew() returns one.


JobRecord ​

A snapshot of a stored job, returned by getPendingJobs() and getFailedJobs().

PropertyTypeDescription
idintThe job's ID
namestringThe job's class name
typestringIts type
statusJobStatusIts status
attemptsintAttempts started
maxAttemptsintIts attempt budget
error?stringThe last attempt's error
payloadstringThe codec's JSON
scheduledAtDateTimeImmutableWhen it may run next
expiresAt?DateTimeImmutableIts deadline
createdAtDateTimeImmutableWhen it was enqueued
finishedAt?DateTimeImmutableWhen it completed, failed or expired

JobStatus ​

A string-backed enum: the stored status value and a key of getStats().

CaseValue
JobStatus::Pendingpending
JobStatus::InProgressin_progress
JobStatus::Completedcompleted
JobStatus::Failedfailed
JobStatus::Expiredexpired

Completed, Failed and Expired are finished and can be pruned.


RetryPolicy ​

The retry settings stored with each job. See Retries and Deadlines.

php
public function __construct(
    int $maxAttempts = 3,
    int $baseDelay = 60,
    int $maxDelay = 3600,
)
PropertyDescription
maxAttemptsAttempts in all, the first included
baseDelaySeconds before the first retry
maxDelayThe cap on any delay, in seconds

Throws:

  • InvalidArgumentException — $maxAttempts below 1, or a negative delay

aggressive() ​

php
public static function aggressive(): self

6 attempts; delays from 5 seconds up to 5 minutes.

lenient() ​

php
public static function lenient(): self

10 attempts; delays from 5 minutes up to 2 hours.

backoffSeconds() ​

php
public function backoffSeconds(int $attempt): int

The delay after failed attempt $attempt, from 1: baseDelay, doubled for each further attempt, capped at maxDelay; 0 when either delay is 0.

Throws:

  • InvalidArgumentException — $attempt below 1

Released under the MIT License.