Documentation

AbstractTaskAdapter extends AbstractAdapter
in package
implements TaskAdapterInterface

AbstractYes

Adapter abstract class

Tags
category

Pop

author

Nick Sagona, III nick@popphp.org

copyright

Copyright (c) 2009-2026 Nick Sagona, III

license

https://www.popphp.org/license New BSD License

version
3.0.0

Table of Contents

Interfaces

TaskAdapterInterface
Adapter interface

Constants

TASK_CLAIM_TTL  = 90
How long, in seconds, a claim blocks a *same-window* re-claim.

Properties

$priority  : string
Queue priority

Methods

__construct()  : mixed
Constructor
bury()  : AdapterInterface
Move a job to the dead-letter store (terminal)
claimTaskRun()  : bool
Atomically claim a task's current due-window
clear()  : AdapterInterface
Clear pending and reserved jobs (not dead-letter jobs)
clearDead()  : AdapterInterface
clearTasks()  : AbstractTaskAdapter
Clear all scheduled task
count()  : int
Count of pending + reserved jobs
countDead()  : int
delete()  : AdapterInterface
Permanently remove a job (success/ack)
deleteDeadJob()  : AdapterInterface
getAllTasks()  : array<string|int, mixed>
Get every scheduled task, keyed by task ID.
getDeadJob()  : mixed
getDeadJobs()  : array<string|int, mixed>
getPriority()  : string
getTask()  : Task|null
Get scheduled task
getTaskCount()  : int
Get scheduled tasks count
getTasks()  : array<string|int, mixed>
Get scheduled tasks
hasDeadJobs()  : bool
hasJobs()  : bool
Whether there are pending or reserved jobs
hasTasks()  : bool
Has scheduled tasks
isFifo()  : bool
isFilo()  : bool
isLifo()  : bool
isLilo()  : bool
push()  : AdapterInterface
Push a job onto the queue
release()  : AdapterInterface
Put a reserved job back to pending. $delay overrides the job's own backoff schedule when given; otherwise release() computes the delay from $job->getBackoffDelay().
removeTask()  : AbstractTaskAdapter
Remove scheduled task
reserve()  : AbstractJob|null
Atomically claim the next eligible job and lease it. Returns null if nothing is eligible (no pending jobs due, or all reserved jobs have a live lease).
retryDeadJob()  : AdapterInterface
Move a dead-letter job back to pending
schedule()  : AbstractTaskAdapter
Schedule job with queue
setPriority()  : AbstractAdapter
updateTask()  : AbstractTaskAdapter
Update scheduled task

Constants

TASK_CLAIM_TTL

How long, in seconds, a claim blocks a *same-window* re-claim.

protected mixed TASK_CLAIM_TTL = 90

Shared by every concrete adapter's claimTaskRun() implementation. Not configurable - it has no relationship to any task's cron recurrence interval (the explicit window value each implementation compares against is what makes that safe). It does need to outlast the longest window a claim must survive: a claim is never refreshed or released while its task runs, and a coarse (non-sub-minute) task is due across its entire ~60-second window (evaluate() stays true for the whole minute, not just at :00), so a second worker can legitimately re-evaluate the same coarse task's window many seconds after the first worker claimed it. 90 seconds covers a full 60-second coarse window plus slack, not just one claim-then-execute round trip.

Properties

Methods

__construct()

Constructor

public __construct([string|null $priority = null ]) : mixed
Parameters
$priority : string|null = null

claimTaskRun()

Atomically claim a task's current due-window

public abstract claimTaskRun(string $taskId, string $window) : bool
Parameters
$taskId : string
$window : string
Return values
bool

count()

Count of pending + reserved jobs

public abstract count() : int
Return values
int

getAllTasks()

Get every scheduled task, keyed by task ID.

public getAllTasks() : array<string|int, mixed>

Concrete, not abstract, so an adapter only overrides it if its storage can genuinely do better than one fetch per task - which the Database and Redis adapters both can, and do. This fallback is the loop it replaces, kept so that adding the method to TaskAdapterInterface doesn't oblige every adapter to reimplement it.

Return values
array<string|int, mixed>

taskId => Task

getDeadJob()

public abstract getDeadJob(string $jobId[, bool $unserialize = true ]) : mixed
Parameters
$jobId : string
$unserialize : bool = true

getDeadJobs()

public abstract getDeadJobs([bool $unserialize = true ]) : array<string|int, mixed>
Parameters
$unserialize : bool = true
Return values
array<string|int, mixed>

getTask()

Get scheduled task

public abstract getTask(string $taskId) : Task|null
Parameters
$taskId : string
Return values
Task|null

getTaskCount()

Get scheduled tasks count

public abstract getTaskCount() : int
Return values
int

getTasks()

Get scheduled tasks

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

hasDeadJobs()

public abstract hasDeadJobs() : bool
Return values
bool

hasJobs()

Whether there are pending or reserved jobs

public abstract hasJobs() : bool
Return values
bool

hasTasks()

Has scheduled tasks

public abstract hasTasks() : bool
Return values
bool

release()

Put a reserved job back to pending. $delay overrides the job's own backoff schedule when given; otherwise release() computes the delay from $job->getBackoffDelay().

public abstract release(AbstractJob $job[, int|null $delay = null ]) : AdapterInterface
Parameters
$job : AbstractJob
$delay : int|null = null
Return values
AdapterInterface

reserve()

Atomically claim the next eligible job and lease it. Returns null if nothing is eligible (no pending jobs due, or all reserved jobs have a live lease).

public abstract reserve() : AbstractJob|null
Return values
AbstractJob|null

        
On this page

Search results