1 | <?php |
||
14 | final class Subscriber |
||
15 | { |
||
16 | private $driver; |
||
17 | private $consumer; |
||
18 | private $eventBus; |
||
19 | |||
20 | 10 | public function __construct(Driver $driver, SerializedEnvelopeConsumer $consumer, MessageBus $eventBus = null) |
|
26 | |||
27 | /** |
||
28 | * @param ExitStrategy $exitStrategy |
||
29 | * @param callable|null $callback Callback that is called after job is consumed with args: count, job |
||
30 | * @param int|null $waitTime Time to wait before consuming another job |
||
31 | * @param int $maxAttempts The number of times to attempt a job before marking as failed, 0 for unlimited |
||
32 | * |
||
33 | * @return string |
||
34 | */ |
||
35 | 9 | public function subscribe(ExitStrategy $exitStrategy, callable $callback = null, $waitTime = null, $maxAttempts = 50) |
|
54 | |||
55 | /** |
||
56 | * @param int $count |
||
57 | * @param Job $job |
||
58 | * @param callable|int $callback |
||
59 | */ |
||
60 | 5 | private function executeCallback($count, Job $job, callable $callback = null) |
|
68 | |||
69 | /** |
||
70 | * @param Job $job |
||
71 | * @param int $maxAttempts |
||
72 | */ |
||
73 | 5 | private function consume(Job $job, $maxAttempts) |
|
83 | |||
84 | /** |
||
85 | * @param Job $job |
||
86 | * @param int $maxAttempts |
||
87 | */ |
||
88 | 4 | private function handleFailedJob(Job $job, $maxAttempts) |
|
101 | |||
102 | /** |
||
103 | * @param object $event |
||
104 | */ |
||
105 | 4 | private function handleEvent($event) |
|
113 | } |
||
114 |