1 | <?php |
||
30 | class Dispatcher implements LoggerAwareInterface |
||
31 | { |
||
32 | /** |
||
33 | * @var array |
||
34 | */ |
||
35 | private $connectionPool; |
||
36 | |||
37 | /** |
||
38 | * @var ServiceClientFactory |
||
39 | */ |
||
40 | private $clientFactory; |
||
41 | |||
42 | /** |
||
43 | * @var NotificationBuilder |
||
44 | */ |
||
45 | private $notificationBuilder; |
||
46 | |||
47 | /** |
||
48 | * @var ResponseHandler |
||
49 | */ |
||
50 | private $responseHandler; |
||
51 | |||
52 | /** |
||
53 | * @var LoggerInterface |
||
54 | */ |
||
55 | private $logger; |
||
56 | |||
57 | /** |
||
58 | * @param ServiceClientFactory $clientFactory |
||
59 | * @param NotificationBuilder $notificationBuilder |
||
60 | * @param ResponseHandler $responseHandler |
||
61 | */ |
||
62 | public function __construct( |
||
73 | |||
74 | /** |
||
75 | * @param LoggerInterface $logger |
||
76 | * @return $this |
||
77 | */ |
||
78 | public function setLogger(LoggerInterface $logger) |
||
83 | |||
84 | /** |
||
85 | * @param bool $isDevelopment |
||
86 | * @return $this |
||
87 | */ |
||
88 | public function setDevelopmentMode($isDevelopment) |
||
93 | |||
94 | /** |
||
95 | * Gets a service client connection by service name |
||
96 | * |
||
97 | * @param string $serviceName |
||
98 | * @return ServiceClientInterface |
||
99 | */ |
||
100 | public function getConnection($serviceName) |
||
108 | |||
109 | /** |
||
110 | * Initialize service client connection by service name |
||
111 | * |
||
112 | * @param string $serviceName |
||
113 | * @return $this |
||
114 | */ |
||
115 | public function initConnection($serviceName) |
||
122 | |||
123 | /** |
||
124 | * Creates a feedback service connection |
||
125 | * |
||
126 | * @param string $serviceName |
||
127 | * @return ServiceClientInterface |
||
128 | */ |
||
129 | public function initFeedbackConnection($serviceName) |
||
133 | |||
134 | /** |
||
135 | * @return ResponseHandler |
||
136 | */ |
||
137 | public function getResponseHandler() |
||
141 | |||
142 | /** |
||
143 | * Build notification and send it to notification service |
||
144 | * |
||
145 | * @param MessageInterface $message |
||
146 | * @return $this |
||
147 | */ |
||
148 | public function dispatch(MessageInterface $message) |
||
161 | |||
162 | /** |
||
163 | * Tries to dispatch all messages to notification service |
||
164 | * |
||
165 | * @param MessageCollection $messages |
||
166 | * @return $this |
||
167 | */ |
||
168 | public function dispatchAll(MessageCollection $messages) |
||
180 | |||
181 | /** |
||
182 | * Tries to connect and send a notification |
||
183 | * |
||
184 | * @param Notification $notification |
||
185 | * @return bool |
||
186 | */ |
||
187 | public function sendNotification(Notification $notification) |
||
227 | |||
228 | /** |
||
229 | * Tries to connect and load feedback data |
||
230 | * |
||
231 | * @return $this |
||
232 | * @throws RuntimeException |
||
233 | * @throws \Exception |
||
234 | */ |
||
235 | public function loadFeedback() |
||
263 | } |
||
264 |