1 | <?php |
||
7 | class Consumer |
||
8 | { |
||
9 | /** |
||
10 | * @var QueueReader |
||
11 | */ |
||
12 | protected $queueReader; |
||
13 | |||
14 | /** |
||
15 | * Consumer constructor. |
||
16 | * @param QueueReader $queueReader |
||
17 | */ |
||
18 | public function __construct(QueueReader $queueReader) |
||
22 | |||
23 | /** |
||
24 | * Consumes tasks indefinitely in a blocking manner |
||
25 | * @param callable $callback Callable that'll be invoked when a message is received |
||
26 | * @param int $timeout (optional) If specified, the process will block a max of $timeout seconds. Indefinitely if 0 |
||
27 | */ |
||
28 | public function consume(callable $callback, $timeout=0) |
||
38 | |||
39 | /** |
||
40 | * Consumes a single task in a blocking manner |
||
41 | * @param callable $callback Callable that'll be invoked when a message is received |
||
42 | * @param int $timeout The process will block a max of $timeout seconds, or indefinitely if 0 |
||
43 | */ |
||
44 | public function consumeOnce(callable $callback, $timeout) |
||
48 | |||
49 | /** |
||
50 | * Purges all messages from the queue |
||
51 | */ |
||
52 | public function purge() |
||
56 | } |