PHP Class UrbanIndo\Yii2\Queue\Queue

Since: 2015.02.24
Author: Petra Barus ([email protected])
Inheritance: extends yii\base\Component
Afficher le fichier Open project: urbanindo/yii2-queue Class Usage Examples

Méthodes publiques

Свойство Type Description
$module yii\base\Module To add the module, create a new module in the config e.g. create a module named 'task'. 'modules' => [ 'task' => [ 'class' => 'app\modules\task\Module', ] ] and then add the module to the queue config. 'components' => [ 'queue' => [ 'module' => 'task' ] ]
$releaseOnFailure boolean This will release automatically on execution failure. i.e. when the run method returns false or catch exception.
$serializer string Choose the serializer.

Méthodes publiques

Méthode Description
delete ( UrbanIndo\Yii2\Queue\Job $job ) : boolean Delete the job. This will trigger event EVENT_BEFORE_DELETE and EVENT_AFTER_DELETE.
fetch ( ) : UrbanIndo\Yii2\Queue\Job | boolean Return next job from the queue. This will trigger event EVENT_BEFORE_FETCH and event EVENT_AFTER_FETCH
getSize ( ) : integer Returns the number of queue size.
init ( ) : void Initializes the module.
post ( UrbanIndo\Yii2\Queue\Job &$job ) : boolean Post new job to the queue. This will trigger event EVENT_BEFORE_POST and EVENT_AFTER_POST.
purge ( ) : boolean Purge the whole queue.
release ( UrbanIndo\Yii2\Queue\Job $job ) : boolean Release the job. This will trigger event EVENT_BEFORE_RELEASE and EVENT_AFTER_RELEASE.
run ( UrbanIndo\Yii2\Queue\Job $job ) : void Run the job.

Méthodes protégées

Méthode Description
deleteJob ( UrbanIndo\Yii2\Queue\Job $job ) : boolean Delete the job. Override this for the queue implementation.
deserialize ( string $message ) : UrbanIndo\Yii2\Queue\Job Deserialize job to be executed.
deserializeMessage ( array $array ) : array
fetchJob ( ) : UrbanIndo\Yii2\Queue\Job | boolean Return next job from the queue. Override this for queue implementation.
postJob ( UrbanIndo\Yii2\Queue\Job $job ) : boolean Post new job to the queue. Override this for queue implementation.
releaseJob ( UrbanIndo\Yii2\Queue\Job $job ) : boolean Release the job. Override this for the queue implementation.
serialize ( UrbanIndo\Yii2\Queue\Job $job ) : string Pack job so that it can be send.
serializeMessage ( mixed $array ) : array

Method Details

delete() public méthode

Delete the job. This will trigger event EVENT_BEFORE_DELETE and EVENT_AFTER_DELETE.
public delete ( UrbanIndo\Yii2\Queue\Job $job ) : boolean
$job UrbanIndo\Yii2\Queue\Job The job to delete.
Résultat boolean whether the operation succeed.

deleteJob() abstract protected méthode

Delete the job. Override this for the queue implementation.
abstract protected deleteJob ( UrbanIndo\Yii2\Queue\Job $job ) : boolean
$job UrbanIndo\Yii2\Queue\Job The job to delete.
Résultat boolean whether the operation succeed.

deserialize() protected méthode

Deserialize job to be executed.
protected deserialize ( string $message ) : UrbanIndo\Yii2\Queue\Job
$message string The json string.
Résultat UrbanIndo\Yii2\Queue\Job The job.

deserializeMessage() protected méthode

protected deserializeMessage ( array $array ) : array
$array array The message to be deserialize.
Résultat array

fetch() public méthode

Return next job from the queue. This will trigger event EVENT_BEFORE_FETCH and event EVENT_AFTER_FETCH
public fetch ( ) : UrbanIndo\Yii2\Queue\Job | boolean
Résultat UrbanIndo\Yii2\Queue\Job | boolean the job or false if not found.

fetchJob() abstract protected méthode

Return next job from the queue. Override this for queue implementation.
abstract protected fetchJob ( ) : UrbanIndo\Yii2\Queue\Job | boolean
Résultat UrbanIndo\Yii2\Queue\Job | boolean the job or false if not found.

getSize() abstract public méthode

Returns the number of queue size.
abstract public getSize ( ) : integer
Résultat integer

init() public méthode

Initializes the module.
public init ( ) : void
Résultat void

post() public méthode

Post new job to the queue. This will trigger event EVENT_BEFORE_POST and EVENT_AFTER_POST.
public post ( UrbanIndo\Yii2\Queue\Job &$job ) : boolean
$job UrbanIndo\Yii2\Queue\Job The job.
Résultat boolean Whether operation succeed.

postJob() abstract protected méthode

Post new job to the queue. Override this for queue implementation.
abstract protected postJob ( UrbanIndo\Yii2\Queue\Job $job ) : boolean
$job UrbanIndo\Yii2\Queue\Job The job.
Résultat boolean Whether operation succeed.

purge() abstract public méthode

Purge the whole queue.
abstract public purge ( ) : boolean
Résultat boolean

release() public méthode

Release the job. This will trigger event EVENT_BEFORE_RELEASE and EVENT_AFTER_RELEASE.
public release ( UrbanIndo\Yii2\Queue\Job $job ) : boolean
$job UrbanIndo\Yii2\Queue\Job The job to delete.
Résultat boolean whether the operation succeed.

releaseJob() abstract protected méthode

Release the job. Override this for the queue implementation.
abstract protected releaseJob ( UrbanIndo\Yii2\Queue\Job $job ) : boolean
$job UrbanIndo\Yii2\Queue\Job The job to release.
Résultat boolean whether the operation succeed.

run() public méthode

Run the job.
public run ( UrbanIndo\Yii2\Queue\Job $job ) : void
$job UrbanIndo\Yii2\Queue\Job The job to be executed.
Résultat void

serialize() protected méthode

Pack job so that it can be send.
protected serialize ( UrbanIndo\Yii2\Queue\Job $job ) : string
$job UrbanIndo\Yii2\Queue\Job The job to serialize.
Résultat string JSON string.

serializeMessage() protected méthode

protected serializeMessage ( mixed $array ) : array
$array mixed Array to serialize.
Résultat array

Property Details

$module public_oe property

To add the module, create a new module in the config e.g. create a module named 'task'. 'modules' => [ 'task' => [ 'class' => 'app\modules\task\Module', ] ] and then add the module to the queue config. 'components' => [ 'queue' => [ 'module' => 'task' ] ]
public Module,yii\base $module
Résultat yii\base\Module

$releaseOnFailure public_oe property

This will release automatically on execution failure. i.e. when the run method returns false or catch exception.
public bool $releaseOnFailure
Résultat boolean

$serializer public_oe property

Choose the serializer.
public string $serializer
Résultat string