PHP Class Queue\Model\Table\QueuedJobsTable

Inheritance: extends Cake\ORM\Table
Mostrar archivo Open project: dereuromark/cakephp-queue Class Usage Examples

Public Properties

Property Type Description
$findMethods array
$rateHistory array

Protected Properties

Property Type Description
$_key string | null

Public Methods

Method Description
cleanOldJobs ( ) : void Cleanup/Delete Completed Jobs.
clearDoublettes ( ) : void FIXME
clearKey ( ) : void Resets worker Identifier
createJob ( string $jobName, array $data = null, array $config = [] ) : Cake\ORM\Entity Add a new Job to the Queue.
getLength ( string | null $type = null ) : integer Returns the number of items in the queue.
getPendingStats ( ) : array Return some statistics about unfinished jobs still in the Database.
getStats ( ) : array Return some statistics about finished jobs still in the Database.
getTypes ( ) : array Return a list of all job types in the Queue.
initConfig ( ) : void
initialize ( array $config ) : void initialize Table
key ( ) : string Generates a unique Identifier for the current worker thread.
lastRun ( ) : array
markJobDone ( Queue\Model\Entity\QueuedJob $job ) : boolean Mark a job as Completed, removing it from the queue.
markJobFailed ( Queue\Model\Entity\QueuedJob $job, string | null $failureMessage = null ) : boolean Mark a job as Failed, incrementing the failed-counter and Requeueing it.
requestJob ( array $capabilities, string | null $group = null ) : Queue\Model\Entity\QueuedJob | null Look for a new job that can be processed with the current abilities and from the specified group (or any if null).
reset ( ) : boolean Reset current jobs
truncate ( ) : void truncate()
updateProgress ( integer $id, float $progress ) : boolean

Protected Methods

Method Description
_findProgress ( string $state, array $query = [], array $results = [] ) : array Custom find method, as in `find('progress', .

Method Details

_findProgress() protected method

..)`.
protected _findProgress ( string $state, array $query = [], array $results = [] ) : array
$state string Current state
$query array Parameters
$results array Results
return array Query/Results based on state

cleanOldJobs() public method

Cleanup/Delete Completed Jobs.
public cleanOldJobs ( ) : void
return void

clearDoublettes() public method

FIXME
public clearDoublettes ( ) : void
return void

clearKey() public method

Resets worker Identifier
public clearKey ( ) : void
return void

createJob() public method

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
public createJob ( string $jobName, array $data = null, array $config = [] ) : Cake\ORM\Entity
$jobName string Job name
$data array Array of data
$config array Config to save along with the job
return Cake\ORM\Entity Saved job entity

getLength() public method

Either returns the number of ALL pending jobs, or the number of pending jobs of the passed type.
public getLength ( string | null $type = null ) : integer
$type string | null Job type to Count
return integer

getPendingStats() public method

Return some statistics about unfinished jobs still in the Database.
public getPendingStats ( ) : array
return array

getStats() public method

TO-DO: rewrite as virtual field
public getStats ( ) : array
return array

getTypes() public method

Return a list of all job types in the Queue.
public getTypes ( ) : array
return array

initConfig() public method

public initConfig ( ) : void
return void

initialize() public method

initialize Table
public initialize ( array $config ) : void
$config array Configuration
return void

key() public method

Useful to identify the currently running processes for this thread.
public key ( ) : string
return string Identifier

lastRun() public method

Deprecation: ?
public lastRun ( ) : array
return array

markJobDone() public method

Mark a job as Completed, removing it from the queue.
public markJobDone ( Queue\Model\Entity\QueuedJob $job ) : boolean
$job Queue\Model\Entity\QueuedJob Job
return boolean Success

markJobFailed() public method

Mark a job as Failed, incrementing the failed-counter and Requeueing it.
public markJobFailed ( Queue\Model\Entity\QueuedJob $job, string | null $failureMessage = null ) : boolean
$job Queue\Model\Entity\QueuedJob Job
$failureMessage string | null Optional message to append to the failure_message field.
return boolean Success

requestJob() public method

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 $capabilities, string | null $group = null ) : Queue\Model\Entity\QueuedJob | null
$capabilities array Available QueueWorkerTasks.
$group string | null Request a job from this group, (from any group if null)
return Queue\Model\Entity\QueuedJob | null

reset() public method

Reset current jobs
public reset ( ) : boolean
return boolean Success

truncate() public method

truncate()
public truncate ( ) : void
return void

updateProgress() public method

public updateProgress ( integer $id, float $progress ) : boolean
$id integer ID of job
$progress float Value from 0 to 1
return boolean Success

Property Details

$_key protected_oe property

protected string|null $_key
return string | null

$findMethods public_oe property

public array $findMethods
return array

$rateHistory public_oe property

public array $rateHistory
return array