Skip to content

Commit

Permalink
Add option constants (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
rybakit authored Jul 17, 2017
1 parent 08eba92 commit 5246581
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 5 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,12 @@ Task::isDelayed()
As you've already seen, to insert a task into a queue you need to call `put()` method, which accepts
two arguments: the data you want to process and optional array of task options, which this particular
queue supports. For example, `fifottl` queue (which we defined earlier in our Lua config file),
supports `delay`, `ttl`, `ttr`, `pri` and `temporary` options:
supports `delay`, `ttl`, `ttr` and `pri` options:

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

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

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

To look at a task without changing its state, use:
Expand Down
20 changes: 20 additions & 0 deletions src/TtlOptions.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

/*
* This file is part of the Tarantool Queue package.
*
* (c) Eugene Leonovich <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Tarantool\Queue;

interface TtlOptions
{
const PRI = 'pri';
const TTL = 'ttl';
const TTR = 'ttr';
const DELAY = 'delay';
}
17 changes: 17 additions & 0 deletions src/UtubeOptions.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

/*
* This file is part of the Tarantool Queue package.
*
* (c) Eugene Leonovich <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Tarantool\Queue;

abstract class UtubeOptions
{
const UTUBE = 'utube';
}
16 changes: 16 additions & 0 deletions src/UtubettlOptions.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

/*
* This file is part of the Tarantool Queue package.
*
* (c) Eugene Leonovich <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Tarantool\Queue;

abstract class UtubettlOptions extends UtubeOptions implements TtlOptions
{
}

0 comments on commit 5246581

Please sign in to comment.