1 | <?php |
||
19 | class MultipleQueueManager implements MultipleQueueManagerInterface, LoggerAwareInterface, CommandRouterInterface |
||
20 | { |
||
21 | |||
22 | /** |
||
23 | * Send drivers array, where keays are pool names. |
||
24 | * |
||
25 | * @var SendDriverInterface[] |
||
26 | */ |
||
27 | private $sendDrivers; |
||
28 | |||
29 | /** |
||
30 | * Default pool name. |
||
31 | * |
||
32 | * @var string |
||
33 | */ |
||
34 | private $defaultPool = ""; |
||
35 | |||
36 | /** |
||
37 | * Logger interface. |
||
38 | * |
||
39 | * @var LoggerInterface |
||
40 | */ |
||
41 | private $logger; |
||
42 | |||
43 | /** |
||
44 | * Pool detector. |
||
45 | * |
||
46 | * @var CachedRouteDetector |
||
47 | */ |
||
48 | private $poolDetector; |
||
49 | |||
50 | 9 | public function __construct(LoggerInterface $logger = null) |
|
51 | { |
||
52 | 9 | if ($logger) { |
|
53 | 1 | $this->logger = $logger; |
|
54 | 1 | } else { |
|
55 | 8 | $this->logger = new NullLogger(); |
|
56 | } |
||
57 | 9 | $this->poolDetector = new CachedRouteDetector(); |
|
58 | 9 | } |
|
59 | |||
60 | /** |
||
61 | * Add new command route. |
||
62 | * |
||
63 | * @param string $commandExpression |
||
64 | * @param string $poolName |
||
65 | */ |
||
66 | 6 | public function addCommandRoute($commandExpression, $poolName) |
|
70 | |||
71 | /** |
||
72 | * {@inheritdoc} |
||
73 | */ |
||
74 | 7 | public function addSendDriver( |
|
84 | |||
85 | /** |
||
86 | * {@inheritdoc} |
||
87 | */ |
||
88 | 8 | public function sendCommand(CommandInterface $command) |
|
100 | |||
101 | /** |
||
102 | * Set logger instance. |
||
103 | * |
||
104 | * @param LoggerInterface $logger |
||
105 | */ |
||
106 | 1 | public function setLogger(LoggerInterface $logger) |
|
107 | { |
||
108 | 1 | $this->logger = $logger; |
|
109 | 1 | } |
|
110 | |||
111 | /** |
||
112 | * Detect correct pool for given command. |
||
113 | * |
||
114 | * @param CommandInterface $command |
||
115 | * @return string |
||
116 | */ |
||
117 | 8 | private function detectPool(CommandInterface $command) |
|
122 | |||
123 | } |
||
124 |