Skip to content

Commit ec281fb

Browse files
author
Eugene Leonovich
committed
Test delayed release()
1 parent 04267b7 commit ec281fb

File tree

2 files changed

+24
-6
lines changed

2 files changed

+24
-6
lines changed

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,8 @@ Or put back into the queue in case it cannot be executed:
144144

145145
```php
146146
$this->queue->release($task->getId());
147-
// or
147+
148+
// for ttl-like queues you can specify a delay
148149
$this->queue->release($task->getId(), ['delay' => 30]);
149150
```
150151

tests/Integration/Ttl.php

+22-5
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
namespace Tarantool\Queue\Tests\Integration;
1313

14+
use Tarantool\Queue\States;
15+
1416
trait Ttl
1517
{
1618
/**
@@ -59,15 +61,30 @@ public function testPriority()
5961
*/
6062
public function testDelay()
6163
{
62-
$task = $this->queue->take(.1);
64+
$task = $this->queue->peek(0);
65+
$this->assertTask($task, 0, States::DELAYED, 'delay_1');
6366

64-
$this->assertNull($task);
67+
sleep(1);
68+
69+
$task = $this->queue->peek(0);
70+
$this->assertTask($task, 0, States::READY, 'delay_1');
71+
}
72+
73+
/**
74+
* @eval queue.tube['%tube_name%']:put('release_0')
75+
* @eval queue.tube['%tube_name%']:take()
76+
*/
77+
public function testDelayedRelease()
78+
{
79+
$this->queue->release(0, ['delay' => 1]);
80+
81+
$task = $this->queue->peek(0);
82+
$this->assertTask($task, 0, States::DELAYED, 'release_0');
6583

6684
sleep(1);
67-
$task = $this->queue->take(.1);
6885

69-
$this->assertTaskInstance($task);
70-
$this->assertSame('delay_1', $task->getData());
86+
$task = $this->queue->peek(0);
87+
$this->assertTask($task, 0, States::READY, 'release_0');
7188
}
7289

7390
/**

0 commit comments

Comments
 (0)