1 | <?php |
||
16 | class Gateway |
||
17 | { |
||
18 | |||
19 | use TimeTrait; |
||
20 | use RedisTrait; |
||
21 | use IdGeneratorTrait; |
||
22 | |||
23 | const QUEUE_DELAYED = 'message_queue:delayed'; |
||
24 | const QUEUE_IMMEDIATE = 'message_queue:immediate'; |
||
25 | const META_DATA = 'message_queue:meta_data'; |
||
26 | const RETRY_TIME = 3600; // try again after 1 hour |
||
27 | |||
28 | /** |
||
29 | * @param string $eventId |
||
30 | * @param string $eventType |
||
31 | * @return bool success |
||
32 | */ |
||
33 | 3 | public function deleteEvent(string $eventId, string $eventType = null) : bool |
|
56 | |||
57 | /** |
||
58 | * @param AbstractEvent $event |
||
59 | * @param int $timestamp |
||
60 | * @return string |
||
61 | */ |
||
62 | public function addEvent(AbstractEvent $event, int $timestamp = 0) |
||
71 | 2 | ||
72 | /** |
||
73 | * @param Job $job |
||
74 | */ |
||
75 | public function addJob(Job $job) |
||
91 | 3 | ||
92 | /** |
||
93 | * @param string $eventType |
||
94 | * @param int $since |
||
95 | * @return Job[] |
||
96 | */ |
||
97 | public function getEventsByType(string $eventType = null, int $since = 0) : array |
||
101 | |||
102 | /** |
||
103 | * @param string $eventType |
||
104 | * @param int $since |
||
105 | * @return Generator|Job[] |
||
106 | */ |
||
107 | public function getEventsByTypeGenerator(string $eventType = null, int $since = 0) : Generator |
||
128 | 2 | ||
129 | 2 | /** |
|
130 | * @param Job $job |
||
131 | 2 | */ |
|
132 | 2 | public function restoreJob(Job $job) |
|
140 | 1 | ||
141 | /** |
||
142 | 1 | * @return int |
|
143 | 1 | */ |
|
144 | public function countAllJobs() : int |
||
151 | 1 | ||
152 | /** |
||
153 | 1 | * @param array $keys |
|
154 | * @return Generator |
||
155 | 1 | */ |
|
156 | 1 | private function getFromTimesQueue(array $keys) : Generator |
|
167 | |||
168 | 1 | /** |
|
169 | * @return Generator |
||
170 | */ |
||
171 | private function getFromImmediateQueue() : Generator |
||
183 | } |
||
184 |
It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.