Class zhuravljov\yii\queue\sync\Driver
Inheritance | zhuravljov\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
Property | Type | Description | Defined By |
---|---|---|---|
$queue | zhuravljov\yii\queue\Queue | zhuravljov\yii\queue\BaseDriver |
Public Methods
Method | Description | Defined By |
---|---|---|
__construct() | zhuravljov\yii\queue\BaseDriver | |
init() | zhuravljov\yii\queue\sync\Driver | |
pop() | Pops message and job from the storage. | zhuravljov\yii\queue\sync\Driver |
purge() | Purges the storage. | zhuravljov\yii\queue\sync\Driver |
push() | Pushes job to the storage. | zhuravljov\yii\queue\sync\Driver |
release() | Releases the message. | zhuravljov\yii\queue\sync\Driver |
Protected Methods
Method | Description | Defined By |
---|---|---|
getQueue() | zhuravljov\yii\queue\BaseDriver |
Method Details
Defined in: zhuravljov\yii\queue\BaseDriver::__construct()
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);
}
Defined in: zhuravljov\yii\queue\BaseDriver::getQueue()
protected zhuravljov\yii\queue\Queue getQueue ( ) |
protected function getQueue()
{
return $this->_queue;
}
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__);
});
}
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;
}
}
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);
}
Releases the message.
public void release ( $message ) | ||
$message |
public function release($message)
{
}