1 | <?php |
||
29 | class Dispatcher implements LoggerAwareInterface |
||
30 | { |
||
31 | /** |
||
32 | * @var array |
||
33 | */ |
||
34 | private $connectionPool; |
||
35 | |||
36 | /** |
||
37 | * @var ServiceClientFactory |
||
38 | */ |
||
39 | private $clientFactory; |
||
40 | |||
41 | /** |
||
42 | * @var NotificationBuilder |
||
43 | */ |
||
44 | private $notificationBuilder; |
||
45 | |||
46 | /** |
||
47 | * @var ResponseHandler |
||
48 | */ |
||
49 | private $responseHandler; |
||
50 | |||
51 | /** |
||
52 | * @var LoggerInterface |
||
53 | */ |
||
54 | private $logger; |
||
55 | |||
56 | /** |
||
57 | * @param ServiceClientFactory $clientFactory |
||
58 | * @param NotificationBuilder $notificationBuilder |
||
59 | * @param ResponseHandler $responseHandler |
||
60 | */ |
||
61 | public function __construct( |
||
72 | |||
73 | /** |
||
74 | * @param LoggerInterface $logger |
||
75 | * @return $this |
||
76 | */ |
||
77 | public function setLogger(LoggerInterface $logger) |
||
82 | |||
83 | /** |
||
84 | * @param bool $isDevelopment |
||
85 | * @return $this |
||
86 | */ |
||
87 | public function setDevelopmentMode($isDevelopment) |
||
92 | |||
93 | /** |
||
94 | * Gets a service client connection by service name |
||
95 | * |
||
96 | * @param string $serviceName |
||
97 | * @return ServiceClientInterface |
||
98 | */ |
||
99 | public function getConnection($serviceName) |
||
107 | |||
108 | /** |
||
109 | * Initialize service client connection by service name |
||
110 | * |
||
111 | * @param string $serviceName |
||
112 | * @return $this |
||
113 | */ |
||
114 | public function initConnection($serviceName) |
||
121 | |||
122 | /** |
||
123 | * Creates a feedback service connection |
||
124 | * |
||
125 | * @param string $serviceName |
||
126 | * @return ServiceClientInterface |
||
127 | */ |
||
128 | public function initFeedbackConnection($serviceName) |
||
132 | |||
133 | /** |
||
134 | * @return ResponseHandler |
||
135 | */ |
||
136 | public function getResponseHandler() |
||
140 | |||
141 | /** |
||
142 | * Tries to dispatch all messages to notification service |
||
143 | * |
||
144 | * @param MessageInterface $message |
||
145 | * @return $this |
||
146 | */ |
||
147 | public function dispatch(MessageInterface $message) |
||
178 | |||
179 | /** |
||
180 | * @param MessageCollection $messages |
||
181 | */ |
||
182 | public function dispatchAll(MessageCollection $messages) |
||
192 | |||
193 | /** |
||
194 | * Tries to connect and load feedback data |
||
195 | * |
||
196 | * @return $this |
||
197 | * @throws RuntimeException |
||
198 | * @throws \Exception |
||
199 | */ |
||
200 | public function loadFeedback() |
||
228 | |||
229 | /** |
||
230 | * Tries to connect and send a message to notification service |
||
231 | * |
||
232 | * @param string $messageIdentifier |
||
233 | */ |
||
234 | private function sendNotifications($messageIdentifier) |
||
250 | } |
||
251 |