1 | <?php |
||
16 | class QueueManager |
||
17 | { |
||
18 | /** |
||
19 | * Queue config |
||
20 | * |
||
21 | * @var array |
||
22 | */ |
||
23 | protected $config = [ |
||
24 | 'queue.default' => 'default', |
||
25 | ]; |
||
26 | |||
27 | /** |
||
28 | * The array of resolved queue connections. |
||
29 | * |
||
30 | * @var array |
||
31 | */ |
||
32 | protected $connections = []; |
||
33 | |||
34 | /** |
||
35 | * The array of resolved queue connectors. |
||
36 | * |
||
37 | * @var array |
||
38 | */ |
||
39 | protected $connectors = []; |
||
40 | |||
41 | /** |
||
42 | * Determine if the driver is connected. |
||
43 | * |
||
44 | * @param string $name |
||
45 | * |
||
46 | * @return bool |
||
47 | */ |
||
48 | public function connected(?string $name = null): bool |
||
52 | |||
53 | /** |
||
54 | * Resolve a queue connection instance. |
||
55 | * |
||
56 | * @param string $name |
||
57 | * |
||
58 | * @return QueueInterface |
||
59 | */ |
||
60 | public function connection(?string $name = null): QueueInterface |
||
73 | |||
74 | /** |
||
75 | * Add a queue connection resolver. |
||
76 | * |
||
77 | * @param string $driver |
||
78 | * @param ConnectorInterface $resolver |
||
79 | * |
||
80 | * @return void |
||
81 | */ |
||
82 | public function addConnector(string $driver, $resolver) |
||
86 | |||
87 | /** |
||
88 | * Register a connection with the manager. |
||
89 | * |
||
90 | * @param array $config |
||
91 | * @param string $name |
||
92 | * |
||
93 | * @return void |
||
94 | */ |
||
95 | public function addConnection(array $config, ?string $name = null) |
||
101 | |||
102 | /** |
||
103 | * Get the name of the default queue connection. |
||
104 | * |
||
105 | * @return string |
||
106 | */ |
||
107 | public function getDefaultDriver(): string |
||
111 | |||
112 | /** |
||
113 | * Set the name of the default queue connection. |
||
114 | * |
||
115 | * @param string $name |
||
116 | * |
||
117 | * @return void |
||
118 | */ |
||
119 | public function setDefaultDriver(string $name) |
||
123 | |||
124 | /** |
||
125 | * Get the full name for the given connection. |
||
126 | * |
||
127 | * @param string $connection |
||
128 | * |
||
129 | * @return string |
||
130 | */ |
||
131 | public function getName(?string $connection = null): string |
||
135 | |||
136 | /** |
||
137 | * Dynamically pass calls to the default connection. |
||
138 | * |
||
139 | * @param string $method |
||
140 | * @param array $parameters |
||
141 | * |
||
142 | * @return mixed |
||
143 | */ |
||
144 | public function __call($method, $parameters) |
||
148 | |||
149 | /** |
||
150 | * Get the queue connection configuration. |
||
151 | * |
||
152 | * @param string $name |
||
153 | * |
||
154 | * @return array |
||
155 | */ |
||
156 | protected function getConfig(string $name): array |
||
164 | |||
165 | /** |
||
166 | * Resolve a queue connection. |
||
167 | * |
||
168 | * @param string $name |
||
169 | * |
||
170 | * @return QueueInterface |
||
171 | */ |
||
172 | protected function resolve(string $name): QueueInterface |
||
180 | |||
181 | /** |
||
182 | * Get the connector for a given driver. |
||
183 | * |
||
184 | * @param string $driver |
||
185 | * |
||
186 | * @return ConnectorInterface |
||
187 | * |
||
188 | * @throws InvalidArgumentException |
||
189 | */ |
||
190 | protected function getConnector(string $driver): ConnectorInterface |
||
198 | } |
||
199 |