QueuedJobsTable
extends BaseTable
in package
Tags
Table of Contents
Constants
- DAY = 86400
- DRIVER_MYSQL = 'Mysql'
- DRIVER_POSTGRES = 'Postgres'
- DRIVER_SQLITE = 'Sqlite'
- DRIVER_SQLSERVER = 'Sqlserver'
- STATS_LIMIT = 100000
- CACHE_GROUPS_TO_CLEAR = []
- CACHES_TO_CLEAR = []
- ID_CACHES_TO_CLEAR = []
Properties
- $rateHistory : array<string, string>
- $WorkerProcesses : QueueProcessesTable|BelongsTo
- $_key : string|null
- $taskFinder : TaskFinder|null
Methods
- addBranchScopeQuery() : SelectQuery
- Add branch-based data scoping to a query.
- afterDelete() : void
- After delete hook to capture impersonation audit trail entries.
- afterSave() : void
- After-save handler for automatic cache invalidation.
- beforeMarshal() : void
- cleanOldJobs() : int
- Cleanup/Delete Completed Jobs.
- clearKey() : void
- Resets worker Identifier
- createConfig() : JobConfig
- createJob() : QueuedJob
- Adds a new job to the queue.
- defaultConnectionName() : string
- set connection name
- deleteMany() : ResultSetInterface<string|int, QueuedJob>|false
- deleteManyOrFail() : ResultSetInterface<string|int, QueuedJob>
- findOrCreate() : QueuedJob
- findQueued() : SelectQuery
- Custom find method, as in `find('queued', ...)`.
- flushFailedJobs() : int
- Removes all failed jobs.
- get() : QueuedJob
- getFailedStatus() : string
- getFullStats() : array<string, array<string, mixed>>
- Returns [ 'JobType' => [ 'YYYY-MM-DD' => INT, ... ] ]
- getLength() : int
- Returns the number of items in the queue.
- getPendingStats() : SelectQuery
- Return some statistics about unfinished jobs still in the Database.
- getScheduledStats() : SelectQuery
- getStats() : array<string|int, QueuedJob>|array<string|int, mixed>
- Return some statistics about finished jobs still in the Database.
- getTypes() : SelectQuery
- Return a list of all job types in the Queue.
- initialize() : void
- initialize Table
- isQueued() : bool
- key() : string
- Generates a unique Identifier for the current worker thread.
- markJobDone() : bool
- Mark a job as Completed, removing it from the queue.
- markJobFailed() : bool
- Mark a job as Failed, without incrementing the "attempts" count due to to it being incremented when fetched.
- newEmptyEntity() : QueuedJob
- newEntities() : array<string|int, QueuedJob>
- newEntity() : QueuedJob
- patchEntities() : array<string|int, QueuedJob>
- patchEntity() : QueuedJob
- requestJob() : QueuedJob|null
- Look for a new job that can be processed with the current abilities and from the specified group (or any if null).
- rerun() : int
- rerunByTask() : int
- reset() : int
- Resets all failed and not yet completed jobs.
- save() : QueuedJob|false
- saveMany() : ResultSetInterface<string|int, QueuedJob>|false
- saveManyOrFail() : ResultSetInterface<string|int, QueuedJob>
- saveOrFail() : QueuedJob
- searchManager() : Manager
- truncate() : void
- truncate()
- updateProgress() : bool
- validationDefault() : Validator
- Default validation rules.
- addFilter() : array<string|int, mixed>
- getDateTime() : DateTime
- Returns a DateTime object from different input.
- getDriverName() : string
- get the name of the driver
- jobTask() : string
- logImpersonationAction() : void
- Record impersonated writes to audit log table.
Constants
DAY
public
int
DAY
= 86400
DRIVER_MYSQL
public
string
DRIVER_MYSQL
= 'Mysql'
DRIVER_POSTGRES
public
string
DRIVER_POSTGRES
= 'Postgres'
DRIVER_SQLITE
public
string
DRIVER_SQLITE
= 'Sqlite'
DRIVER_SQLSERVER
public
string
DRIVER_SQLSERVER
= 'Sqlserver'
STATS_LIMIT
public
int
STATS_LIMIT
= 100000
CACHE_GROUPS_TO_CLEAR
protected
array<string|int, string>
CACHE_GROUPS_TO_CLEAR
= []
Cache groups to clear entirely on save
CACHES_TO_CLEAR
protected
array<string|int, array{string, string}>
CACHES_TO_CLEAR
= []
Static cache entries to clear on save
ID_CACHES_TO_CLEAR
protected
array<string|int, array{string, string}>
ID_CACHES_TO_CLEAR
= []
Entity-ID cache prefixes to clear on save
Properties
$rateHistory
public
array<string, string>
$rateHistory
= []
$WorkerProcesses
public
QueueProcessesTable|BelongsTo
$WorkerProcesses
$_key
protected
string|null
$_key
= null
$taskFinder
protected
TaskFinder|null
$taskFinder
= null
Methods
addBranchScopeQuery()
Add branch-based data scoping to a query.
public
addBranchScopeQuery(SelectQuery $query, array<string|int, int> $branchIDs) : SelectQuery
Child tables should override for custom branch relationships.
Parameters
- $query : SelectQuery
-
The query to modify
- $branchIDs : array<string|int, int>
-
Authorized branch IDs
Return values
SelectQuery —Query with branch filtering
afterDelete()
After delete hook to capture impersonation audit trail entries.
public
afterDelete(EventInterface $event, EntityInterface $entity, ArrayObject $options) : void
Parameters
- $event : EventInterface
-
Delete event
- $entity : EntityInterface
-
Entity being deleted
- $options : ArrayObject
-
Delete options
afterSave()
After-save handler for automatic cache invalidation.
public
afterSave(EventInterface $event, EntityInterface $entity, ArrayObject $options) : void
Parameters
- $event : EventInterface
-
The afterSave event
- $entity : EntityInterface
-
The saved entity
- $options : ArrayObject
-
Save options
beforeMarshal()
public
beforeMarshal(EventInterface $event, ArrayObject<string, mixed> $data, ArrayObject<string, mixed> $options) : void
Parameters
- $event : EventInterface
- $data : ArrayObject<string, mixed>
- $options : ArrayObject<string, mixed>
cleanOldJobs()
Cleanup/Delete Completed Jobs.
public
cleanOldJobs() : int
Return values
intclearKey()
Resets worker Identifier
public
clearKey() : void
createConfig()
public
createConfig() : JobConfig
Return values
JobConfigcreateJob()
Adds a new job to the queue.
public
createJob(string $jobTask[, object|array<string, mixed>|null $data = null ][, JobConfig|array<string, mixed> $config = [] ]) : QueuedJob
Config
- priority: 1-10, defaults to 5
- notBefore: Optional date which must not be preceded
- group: Used to group similar QueuedJobs
- reference: An optional reference string
- status: To set an initial status text
Parameters
- $jobTask : string
-
Job task name or FQCN.
- $data : object|array<string, mixed>|null = null
-
Array of data or DTO like object.
- $config : JobConfig|array<string, mixed> = []
-
Config to save along with the job.
Return values
QueuedJob —Saved job entity
defaultConnectionName()
set connection name
public
static defaultConnectionName() : string
Return values
stringdeleteMany()
public
deleteMany(iterable<string|int, mixed> $entities[, array<string|int, mixed> $options = = '[]' ]) : ResultSetInterface<string|int, QueuedJob>|false
Parameters
- $entities : iterable<string|int, mixed>
- $options : array<string|int, mixed> = = '[]'
Return values
ResultSetInterface<string|int, QueuedJob>|falsedeleteManyOrFail()
public
deleteManyOrFail(iterable<string|int, mixed> $entities[, array<string|int, mixed> $options = = '[]' ]) : ResultSetInterface<string|int, QueuedJob>
Parameters
- $entities : iterable<string|int, mixed>
- $options : array<string|int, mixed> = = '[]'
Return values
ResultSetInterface<string|int, QueuedJob>findOrCreate()
public
findOrCreate(mixed $search[, callable|null $callback = = 'null' ][, array<string|int, mixed> $options = = '[]' ]) : QueuedJob
Parameters
- $search : mixed
- $callback : callable|null = = 'null'
- $options : array<string|int, mixed> = = '[]'
Return values
QueuedJobfindQueued()
Custom find method, as in `find('queued', ...)`.
public
findQueued(SelectQuery $query[, array<string, mixed> $options = [] ]) : SelectQuery
Parameters
- $query : SelectQuery
-
The query to find with
- $options : array<string, mixed> = []
-
The options to find with
Return values
SelectQuery —The query builder
flushFailedJobs()
Removes all failed jobs.
public
flushFailedJobs() : int
Return values
int —Count of deleted rows
get()
public
get(mixed $primaryKey[, array<string|int, mixed>|string $finder = = '\'all\'' ][, CacheInterface|string|null $cache = = 'null' ][, Closure|string|null $cacheKey = = 'null' ], mixed ...$args) : QueuedJob
Parameters
- $primaryKey : mixed
- $finder : array<string|int, mixed>|string = = '\'all\''
- $cache : CacheInterface|string|null = = 'null'
- $cacheKey : Closure|string|null = = 'null'
- $args : mixed
Return values
QueuedJobgetFailedStatus()
public
getFailedStatus(QueuedJob $queuedTask, array<string, array<string, mixed>> $taskConfiguration) : string
Parameters
- $queuedTask : QueuedJob
- $taskConfiguration : array<string, array<string, mixed>>
Return values
stringgetFullStats()
Returns [ 'JobType' => [ 'YYYY-MM-DD' => INT, ... ] ]
public
getFullStats([string|null $jobTask = null ]) : array<string, array<string, mixed>>
Parameters
- $jobTask : string|null = null
Return values
array<string, array<string, mixed>>getLength()
Returns the number of items in the queue.
public
getLength([string|null $type = null ]) : int
Either returns the number of ALL pending jobs, or the number of pending jobs of the passed type.
Parameters
- $type : string|null = null
-
Job type to Count
Return values
intgetPendingStats()
Return some statistics about unfinished jobs still in the Database.
public
getPendingStats() : SelectQuery
Return values
SelectQuerygetScheduledStats()
public
getScheduledStats() : SelectQuery
Return values
SelectQuerygetStats()
Return some statistics about finished jobs still in the Database.
public
getStats([bool $disableHydration = false ]) : array<string|int, QueuedJob>|array<string|int, mixed>
TO-DO: rewrite as virtual field
Parameters
- $disableHydration : bool = false
Return values
array<string|int, QueuedJob>|array<string|int, mixed>getTypes()
Return a list of all job types in the Queue.
public
getTypes() : SelectQuery
Return values
SelectQueryinitialize()
initialize Table
public
initialize(array<string, mixed> $config) : void
Parameters
- $config : array<string, mixed>
-
Configuration
isQueued()
public
isQueued(string $reference[, string|null $jobTask = null ]) : bool
Parameters
- $reference : string
- $jobTask : string|null = null
Tags
Return values
boolkey()
Generates a unique Identifier for the current worker thread.
public
key() : string
Useful to identify the currently running processes for this thread.
Return values
string —Identifier
markJobDone()
Mark a job as Completed, removing it from the queue.
public
markJobDone(QueuedJob $job) : bool
Parameters
- $job : QueuedJob
-
Job
Return values
bool —Success
markJobFailed()
Mark a job as Failed, without incrementing the "attempts" count due to to it being incremented when fetched.
public
markJobFailed(QueuedJob $job[, string|null $failureMessage = null ]) : bool
Parameters
- $job : QueuedJob
-
Job
- $failureMessage : string|null = null
-
Optional message to append to the failure_message field.
Return values
bool —Success
newEmptyEntity()
public
newEmptyEntity() : QueuedJob
Return values
QueuedJobnewEntities()
public
newEntities(array<string|int, mixed> $data[, array<string|int, mixed> $options = = '[]' ]) : array<string|int, QueuedJob>
Parameters
- $data : array<string|int, mixed>
- $options : array<string|int, mixed> = = '[]'
Return values
array<string|int, QueuedJob>newEntity()
public
newEntity(array<string|int, mixed> $data[, array<string|int, mixed> $options = = '[]' ]) : QueuedJob
Parameters
- $data : array<string|int, mixed>
- $options : array<string|int, mixed> = = '[]'
Return values
QueuedJobpatchEntities()
public
patchEntities(iterable<string|int, mixed> $entities, array<string|int, mixed> $data[, array<string|int, mixed> $options = = '[]' ]) : array<string|int, QueuedJob>
Parameters
- $entities : iterable<string|int, mixed>
- $data : array<string|int, mixed>
- $options : array<string|int, mixed> = = '[]'
Return values
array<string|int, QueuedJob>patchEntity()
public
patchEntity(EntityInterface $entity, array<string|int, mixed> $data[, array<string|int, mixed> $options = = '[]' ]) : QueuedJob
Parameters
- $entity : EntityInterface
- $data : array<string|int, mixed>
- $options : array<string|int, mixed> = = '[]'
Return values
QueuedJobrequestJob()
Look for a new job that can be processed with the current abilities and from the specified group (or any if null).
public
requestJob(array<string, array<string, mixed>> $tasks[, array<string|int, string> $groups = [] ][, array<string|int, string> $types = [] ]) : QueuedJob|null
Parameters
- $tasks : array<string, array<string, mixed>>
-
Available QueueWorkerTasks.
- $groups : array<string|int, string> = []
-
Request a job from these groups (or exclude certain groups), or any otherwise.
- $types : array<string|int, string> = []
-
Request a job from these types (or exclude certain types), or any otherwise.
Return values
QueuedJob|nullrerun()
public
rerun(int $id) : int
Parameters
- $id : int
Return values
intrerunByTask()
public
rerunByTask(string $task[, string|null $reference = null ]) : int
Parameters
- $task : string
- $reference : string|null = null
Return values
intreset()
Resets all failed and not yet completed jobs.
public
reset([int|null $id = null ][, bool $full = false ]) : int
Parameters
- $id : int|null = null
- $full : bool = false
-
Also currently running jobs.
Return values
int —Success
save()
public
save(EntityInterface $entity[, array<string|int, mixed> $options = = '[]' ]) : QueuedJob|false
Parameters
- $entity : EntityInterface
- $options : array<string|int, mixed> = = '[]'
Return values
QueuedJob|falsesaveMany()
public
saveMany(iterable<string|int, mixed> $entities[, array<string|int, mixed> $options = = '[]' ]) : ResultSetInterface<string|int, QueuedJob>|false
Parameters
- $entities : iterable<string|int, mixed>
- $options : array<string|int, mixed> = = '[]'
Return values
ResultSetInterface<string|int, QueuedJob>|falsesaveManyOrFail()
public
saveManyOrFail(iterable<string|int, mixed> $entities[, array<string|int, mixed> $options = = '[]' ]) : ResultSetInterface<string|int, QueuedJob>
Parameters
- $entities : iterable<string|int, mixed>
- $options : array<string|int, mixed> = = '[]'
Return values
ResultSetInterface<string|int, QueuedJob>saveOrFail()
public
saveOrFail(EntityInterface $entity[, array<string|int, mixed> $options = = '[]' ]) : QueuedJob
Parameters
- $entity : EntityInterface
- $options : array<string|int, mixed> = = '[]'
Return values
QueuedJobsearchManager()
public
searchManager() : Manager
Return values
Managertruncate()
truncate()
public
truncate() : void
updateProgress()
public
updateProgress(int $id, float $progress[, string|null $status = null ]) : bool
Parameters
- $id : int
-
ID of job
- $progress : float
-
Value from 0 to 1
- $status : string|null = null
Return values
bool —Success
validationDefault()
Default validation rules.
public
validationDefault(Validator $validator) : Validator
Parameters
- $validator : Validator
-
Validator instance.
Return values
ValidatoraddFilter()
protected
addFilter(array<string|int, mixed> $conditions, string $key, array<string|int, string> $values) : array<string|int, mixed>
Parameters
- $conditions : array<string|int, mixed>
- $key : string
- $values : array<string|int, string>
Return values
array<string|int, mixed>getDateTime()
Returns a DateTime object from different input.
protected
getDateTime([DateTime|string|int|null $notBefore = null ]) : DateTime
Without argument this will be "now".
Parameters
- $notBefore : DateTime|string|int|null = null
Return values
DateTimegetDriverName()
get the name of the driver
protected
getDriverName() : string
Return values
stringjobTask()
protected
jobTask(Task>|string $jobType) : string
Parameters
- $jobType : Task>|string
Return values
stringlogImpersonationAction()
Record impersonated writes to audit log table.
protected
logImpersonationAction(string $defaultOperation, EntityInterface $entity) : void
Parameters
- $defaultOperation : string
-
Operation fallback (save/delete)
- $entity : EntityInterface
-
Affected entity