Total Complexity | 7 |
Total Lines | 75 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
7 | abstract class Queue |
||
8 | { |
||
9 | |||
10 | use RedisClient; |
||
11 | |||
12 | /** |
||
13 | * @param string $queue |
||
14 | * @param string $worker |
||
15 | * @return string |
||
16 | */ |
||
17 | protected static function getProcessingQueueName(string $queue, string $worker) |
||
20 | } |
||
21 | |||
22 | /** |
||
23 | * @param string $queue |
||
24 | * @return string |
||
25 | */ |
||
26 | protected static function getDeadQueueName(string $queue) |
||
29 | } |
||
30 | |||
31 | /** |
||
32 | * @param string $queue |
||
33 | * @param string $source |
||
34 | * @param string $destination |
||
35 | * |
||
36 | * @throws QueueWithoutConnectionException |
||
37 | */ |
||
38 | protected static function moveMessages(string $queue, string $source, string $destination) |
||
39 | { |
||
40 | do { |
||
41 | $value = self::client($queue)->rpoplpush($source, $destination); |
||
42 | } while ($value !== false); |
||
43 | } |
||
44 | |||
45 | /** |
||
46 | * @param string $queue |
||
47 | * @param string $key |
||
48 | * @return bool |
||
49 | * |
||
50 | * @throws QueueWithoutConnectionException |
||
51 | */ |
||
52 | protected static function removeMessages(string $queue, string $key) |
||
53 | { |
||
54 | return (bool) self::client($queue)->del($key); |
||
55 | } |
||
56 | |||
57 | /** |
||
58 | * @param string $queue |
||
59 | * @param string $key |
||
60 | * @return int |
||
61 | * |
||
62 | * @throws QueueWithoutConnectionException |
||
63 | */ |
||
64 | protected static function countMessages(string $queue, string $key) |
||
67 | } |
||
68 | |||
69 | /** |
||
70 | * @param string $queue |
||
71 | * @param string $key |
||
72 | * @param int $start |
||
73 | * @param int $end |
||
74 | * @return array |
||
75 | * |
||
76 | * @throws QueueWithoutConnectionException |
||
77 | */ |
||
78 | protected static function getMessages(string $queue, string $key, int $start, int $end) |
||
85 |