Skip to content

Commit 5246581

Browse files
authored
Add option constants (#12)
1 parent 08eba92 commit 5246581

File tree

4 files changed

+58
-5
lines changed

4 files changed

+58
-5
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,12 @@ Task::isDelayed()
107107
As you've already seen, to insert a task into a queue you need to call `put()` method, which accepts
108108
two arguments: the data you want to process and optional array of task options, which this particular
109109
queue supports. For example, `fifottl` queue (which we defined earlier in our Lua config file),
110-
supports `delay`, `ttl`, `ttr`, `pri` and `temporary` options:
110+
supports `delay`, `ttl`, `ttr` and `pri` options:
111111

112112
```php
113-
$queue->put('foo', ['delay' => 30]);
114-
$queue->put('bar', ['ttl' => 5]);
115-
$queue->put('baz', ['ttr' => 10, 'pri' => 42]);
113+
$queue->put('foo', [TtlOptions::DELAY => 30]);
114+
$queue->put('bar', [TtlOptions::TTL => 5]);
115+
$queue->put('baz', [TtlOptions::TTR => 10, TtlOptions::PRI => 42]);
116116
```
117117

118118
> See the full list of available options [here](https://github.com/tarantool/queue#queue-types).
@@ -150,7 +150,7 @@ Or put back into the queue in case it cannot be executed:
150150
$task = $queue->release($task->getId());
151151

152152
// for *ttl queues you can specify a delay
153-
$task = $queue->release($task->getId(), ['delay' => 30]);
153+
$task = $queue->release($task->getId(), [TtlOptions:DELAY => 30]);
154154
```
155155

156156
To look at a task without changing its state, use:

src/TtlOptions.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Tarantool Queue package.
5+
*
6+
* (c) Eugene Leonovich <gen.work@gmail.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Tarantool\Queue;
13+
14+
interface TtlOptions
15+
{
16+
const PRI = 'pri';
17+
const TTL = 'ttl';
18+
const TTR = 'ttr';
19+
const DELAY = 'delay';
20+
}

src/UtubeOptions.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Tarantool Queue package.
5+
*
6+
* (c) Eugene Leonovich <gen.work@gmail.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Tarantool\Queue;
13+
14+
abstract class UtubeOptions
15+
{
16+
const UTUBE = 'utube';
17+
}

src/UtubettlOptions.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Tarantool Queue package.
5+
*
6+
* (c) Eugene Leonovich <gen.work@gmail.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Tarantool\Queue;
13+
14+
abstract class UtubettlOptions extends UtubeOptions implements TtlOptions
15+
{
16+
}

0 commit comments

Comments
 (0)