|
11 | 11 |
|
12 | 12 | namespace think; |
13 | 13 |
|
14 | | -use InvalidArgumentException; |
15 | | -use think\cache\driver\Redis; |
16 | | -use think\helper\Str; |
17 | 14 | use think\queue\Connector; |
18 | 15 | use think\queue\connector\Database; |
| 16 | +use think\queue\connector\Redis; |
19 | 17 |
|
20 | 18 | /** |
21 | 19 | * Class Queue |
22 | 20 | * @package think\queue |
23 | 21 | * |
24 | | - * @method Connector driver($driver = null) |
25 | 22 | * @mixin Database |
26 | 23 | * @mixin Redis |
27 | 24 | */ |
28 | | -class Queue extends Factory |
| 25 | +class Queue extends Manager |
29 | 26 | { |
30 | 27 | protected $namespace = '\\think\\queue\\connector\\'; |
31 | 28 |
|
32 | | - /** |
33 | | - * Get the queue connector configuration. |
34 | | - * |
35 | | - * @param string $name |
36 | | - * @return array |
37 | | - */ |
38 | | - protected function getConfig($name) |
| 29 | + protected function resolveType(string $name) |
39 | 30 | { |
40 | | - return $this->app->config->get("queue.connections.{$name}", ['type' => 'sync']); |
| 31 | + return $this->app->config->get("queue.connections.{$name}.type", 'sync'); |
41 | 32 | } |
42 | 33 |
|
43 | | - protected function createDriver($name) |
| 34 | + protected function resolveConfig(string $name) |
44 | 35 | { |
45 | | - $driver = $this->getConfig($name)['type']; |
46 | | - |
47 | | - $class = false !== strpos($driver, '\\') ? $driver : $this->namespace . Str::studly($driver); |
| 36 | + return $this->app->config->get("queue.connections.{$name}"); |
| 37 | + } |
48 | 38 |
|
| 39 | + protected function createDriver(string $name) |
| 40 | + { |
49 | 41 | /** @var Connector $driver */ |
50 | | - if (class_exists($class)) { |
51 | | - $driver = $this->app->invokeClass($class, [$this->getConfig($driver)]); |
52 | | - |
53 | | - return $driver->setApp($this->app) |
54 | | - ->setConnection($name); |
55 | | - } |
| 42 | + $driver = parent::createDriver($name); |
56 | 43 |
|
57 | | - throw new InvalidArgumentException("Driver [$driver] not supported."); |
| 44 | + return $driver->setApp($this->app) |
| 45 | + ->setConnection($name); |
58 | 46 | } |
59 | 47 |
|
60 | 48 | /** |
|
0 commit comments