Class zhuravljov\yii\queue\sync\Driver

Inheritancezhuravljov\yii\queue\sync\Driver » zhuravljov\yii\queue\BaseDriver » yii\base\Object
Source Code https://github.com/yiisoft/yii2-queue/blob/master/src/sync/Driver.php

Class SyncDriver

Public Properties

Hide inherited properties

Property Type Description Defined By
$queue zhuravljov\yii\queue\Queue zhuravljov\yii\queue\BaseDriver

Protected Methods

Hide inherited methods

Method Description Defined By
getQueue() zhuravljov\yii\queue\BaseDriver

Method Details

Hide inherited methods

__construct() public method
public void __construct ( zhuravljov\yii\queue\Queue $queue, $config = [] )
$queue zhuravljov\yii\queue\Queue
$config

                public function __construct(Queue $queue, $config = [])
{
    $this->_queue = $queue;
    parent::__construct($config);
}

            
getQueue() protected method
protected zhuravljov\yii\queue\Queue getQueue ( )

                protected function getQueue()
{
    return $this->_queue;
}

            
init() public method

public void init ( )

                public function init()
{
    parent::init();
    Yii::$app->on(Application::EVENT_AFTER_REQUEST, function () {
        Yii::info('Worker has been started.', __CLASS__);
        ob_start();
        $count = 0;
        while ($this->getQueue()->work(false)) {
            $count++;
        }
        Yii::trace(ob_get_clean(), __CLASS__);
        Yii::info("$count jobs have been complete.", __CLASS__);
    });
}

            
pop() public method

Pops message and job from the storage.

public boolean pop ( &$message, &$job )
$message mixed
$job zhuravljov\yii\queue\Job

                public function pop(&$message, &$job)
{
    $message = array_shift($this->_messages);
    if ($message !== null) {
        $job = unserialize($message);
        return true;
    } else {
        return false;
    }
}

            
purge() public method

Purges the storage.

public void purge ( )

                public function purge()
{
    $this->_messages = [];
}

            
push() public method

Pushes job to the storage.

public mixed push ( $job )
$job zhuravljov\yii\queue\Job
return mixed

$message

                public function push($job)
{
    $this->_messages[] = serialize($job);
}

            
release() public method

Releases the message.

public void release ( $message )
$message

                public function release($message)
{
}