Skip to content

Commit c930937

Browse files
committed
vyuldashev#225 laravel horizon support
1 parent 43d3889 commit c930937

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

src/Queue/Connectors/RabbitMQConnector.php

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Illuminate\Queue\Events\WorkerStopping;
1212
use Enqueue\AmqpTools\RabbitMqDlxDelayStrategy;
1313
use Illuminate\Queue\Connectors\ConnectorInterface;
14+
use InvalidArgumentException;
1415
use VladimirYuldashev\LaravelQueueRabbitMQ\Horizon\RabbitMQQueue as HorizonRabbitMQQueue;
1516
use VladimirYuldashev\LaravelQueueRabbitMQ\Queue\RabbitMQQueue;
1617
use Interop\Amqp\AmqpConnectionFactory as InteropAmqpConnectionFactory;
@@ -48,18 +49,18 @@ public function connect(array $config): Queue
4849

4950
/** @var AmqpConnectionFactory $factory */
5051
$factory = new $factoryClass([
51-
'dsn' => $config['dsn'],
52-
'host' => $config['host'],
53-
'port' => $config['port'],
54-
'user' => $config['login'],
55-
'pass' => $config['password'],
56-
'vhost' => $config['vhost'],
57-
'ssl_on' => $config['ssl_params']['ssl_on'],
58-
'ssl_verify' => $config['ssl_params']['verify_peer'],
59-
'ssl_cacert' => $config['ssl_params']['cafile'],
60-
'ssl_cert' => $config['ssl_params']['local_cert'],
61-
'ssl_key' => $config['ssl_params']['local_key'],
62-
'ssl_passphrase' => $config['ssl_params']['passphrase'],
52+
'dsn' => Arr::get($config, 'dsn'),
53+
'host' => Arr::get($config, 'host', '127.0.0.1'),
54+
'port' => Arr::get($config, 'port', 5672),
55+
'user' => Arr::get($config, 'login', 'guest'),
56+
'pass' => Arr::get($config, 'password', 'guest'),
57+
'vhost' => Arr::get($config, 'vhost', '/'),
58+
'ssl_on' => Arr::get($config, 'ssl_params.ssl_on', false),
59+
'ssl_verify' => Arr::get($config, 'ssl_params.verify_peer', true),
60+
'ssl_cacert' => Arr::get($config, 'ssl_params.ca_file'),
61+
'ssl_cert' => Arr::get($config, 'ssl_params.local_cert'),
62+
'ssl_key' => Arr::get($config, 'ssl_params.local_key'),
63+
'ssl_passphrase' => Arr::get($config, 'ssl_params.passphrase'),
6364
]);
6465

6566
if ($factory instanceof DelayStrategyAware) {
@@ -75,12 +76,14 @@ public function connect(array $config): Queue
7576

7677
$worker = Arr::get($config, 'worker', 'default');
7778

78-
if($worker === 'default') {
79+
if ($worker === 'default') {
7980
return new RabbitMQQueue($context, $config);
8081
}
8182

82-
if($worker === 'horizon') {
83+
if ($worker === 'horizon') {
8384
return new HorizonRabbitMQQueue($context, $config);
8485
}
86+
87+
throw new InvalidArgumentException('Invalid worker.');
8588
}
8689
}

0 commit comments

Comments
 (0)