1 | <?php |
||
19 | class PredisSubscribeCommandQueue implements SubscribeCommandQueue |
||
20 | { |
||
21 | /** |
||
22 | * @var RedisPubSubAdapter |
||
23 | */ |
||
24 | private $client; |
||
25 | |||
26 | /** |
||
27 | * @var Serializer |
||
28 | */ |
||
29 | private $serializer; |
||
30 | |||
31 | /** |
||
32 | * @var LoggerInterface |
||
33 | */ |
||
34 | private $logger; |
||
35 | |||
36 | /** |
||
37 | * @var callable[] |
||
38 | */ |
||
39 | private $handlers = []; |
||
40 | |||
41 | /** |
||
42 | * @var string |
||
43 | */ |
||
44 | private $queue_name; |
||
45 | |||
46 | /** |
||
47 | * @var bool |
||
48 | */ |
||
49 | private $subscribed = false; |
||
50 | |||
51 | /** |
||
52 | * @param RedisPubSubAdapter $client |
||
53 | * @param Serializer $serializer |
||
54 | * @param LoggerInterface $logger |
||
55 | * @param string $queue_name |
||
56 | */ |
||
57 | 6 | public function __construct( |
|
68 | |||
69 | /** |
||
70 | * Publish command to queue. |
||
71 | * |
||
72 | * @param Command $command |
||
73 | * |
||
74 | * @return bool |
||
75 | */ |
||
76 | 1 | public function publish(Command $command): bool |
|
83 | |||
84 | /** |
||
85 | * Subscribe on command queue. |
||
86 | * |
||
87 | * @param callable $handler |
||
88 | */ |
||
89 | 5 | public function subscribe(callable $handler): void |
|
101 | |||
102 | /** |
||
103 | * Unsubscribe on command queue. |
||
104 | * |
||
105 | * @param callable $handler |
||
106 | * |
||
107 | * @return bool |
||
108 | */ |
||
109 | 1 | public function unsubscribe(callable $handler): bool |
|
121 | |||
122 | /** |
||
123 | * @param mixed $message |
||
124 | */ |
||
125 | 4 | private function handle($message): void |
|
148 | } |
||
149 |