@@ -33,36 +33,30 @@ to the require section of your `composer.json` file.
3333Basic Usage
3434-----------
3535
36- Job class example:
36+ Each task which is sent to queue should be defined as a separate class.
37+ For example, if you need to download and save a file the class may look like the following:
3738
3839``` php
3940class DownloadJob extends Object implements \zhuravljov\yii\queue\Job
4041{
4142 public $url;
4243 public $file;
4344
44- /**
45- * @param Queue $queue which handled the job
46- * @param string|null $jobId job message ID
47- */
48- public function execute($queue, $jobId)
45+ public function execute($queue)
4946 {
5047 file_put_contents($this->file, file_get_contents($this->url));
5148 }
5249}
5350```
5451
55- Pushes job into queue:
52+ Here's how to send a task into queue:
5653
5754``` php
5855Yii::$app->queue->push(new DownloadJob([
5956 'url' => 'http://example.com/image.jpg',
6057 'file' => '/tmp/image.jpg',
6158]));
6259```
63-
64- Method of handling a queue depend on selected driver.
65-
6660Pushes job into queue that run after 5 min:
6761
6862``` php
@@ -72,6 +66,24 @@ Yii::$app->queue->later(new DownloadJob([
7266]), 5 * 60);
7367```
7468
75- But only some drivers support delayed running.
69+ The exact way task is executed depends on the driver used. The most part of drivers can be run using
70+ console commands, which the component registers in your application. For more details see documentation
71+ of a driver.
72+
73+ The component has ability to track status jobs which was pushed into queue.
74+
75+ ``` php
76+ // Push a job into queue and get massage ID.
77+ $id = Yii::$app->queue->push(new SomeJob());
78+
79+ // The job is waiting for execute.
80+ Yii::$app->queue->isWaiting($id);
81+
82+ // Worker gets the job from queue, end executing it.
83+ Yii::$app->queue->isReserved($id);
84+
85+ // Worker has executed the job.
86+ Yii::$app->queue->isDone($id);
87+ ```
7688
7789For more details see [ the guide] ( docs/guide/README.md ) .
0 commit comments