Skip to content

Commit bbfbf19

Browse files
committed
queues: add missing constants
1 parent 0f56e76 commit bbfbf19

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

src/Queue/Connectors/RabbitMQConnector.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121

2222
class RabbitMQConnector implements ConnectorInterface
2323
{
24+
private const WORKER_DEFAULT='default';
25+
private const WORKER_HORIZON='horizon';
26+
2427
/**
2528
* @var Dispatcher
2629
*/
@@ -74,18 +77,18 @@ public function connect(array $config): Queue
7477
$context->close();
7578
});
7679

77-
$worker = Arr::get($config, 'worker', 'default');
80+
$worker = Arr::get($config, 'worker', self::WORKER_DEFAULT);
7881

79-
if ($worker === 'default') {
82+
if ($worker === self::WORKER_DEFAULT) {
8083
return new RabbitMQQueue($context, $config);
8184
}
8285

83-
if ($worker === 'horizon') {
86+
if ($worker === self::WORKER_HORIZON) {
8487
$this->dispatcher->listen(JobFailed::class, RabbitMQFailedEvent::class);
8588

8689
return new HorizonRabbitMQQueue($context, $config);
8790
}
88-
91+
8992
if (class_exists($worker)) {
9093
return new $worker($context, $config);
9194
}

src/Queue/RabbitMQQueue.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
<?php
1+
<?php declare(strict_types=1);
22

33
namespace VladimirYuldashev\LaravelQueueRabbitMQ\Queue;
44

5+
use Exception;
56
use Illuminate\Contracts\Queue\Queue as QueueContract;
67
use Illuminate\Queue\Queue;
78
use Illuminate\Support\Facades\Config as FacadeConfig;
@@ -16,17 +17,18 @@
1617
use Psr\Log\LoggerInterface;
1718
use RuntimeException;
1819
use Throwable;
19-
use Exception;
2020
use VladimirYuldashev\LaravelQueueRabbitMQ\Queue\Jobs\RabbitMQJob;
2121

2222
class RabbitMQQueue extends Queue implements QueueContract
2323
{
24+
private const SLEEP_ON_ERROR=5;
2425
protected $sleepOnError;
2526

2627
protected $queueName;
2728
protected $queueOptions;
2829
protected $exchangeOptions;
2930

31+
3032
/**
3133
* Alternative exchange options to use by producer.
3234
*
@@ -58,7 +60,7 @@ public function __construct(AmqpContext $context, array $config)
5860
$this->exchangeOptions['arguments'] = isset($this->exchangeOptions['arguments']) ?
5961
json_decode($this->exchangeOptions['arguments'], true) : [];
6062

61-
$this->sleepOnError = $config['sleep_on_error'] ?? 5;
63+
$this->sleepOnError = $config['sleep_on_error'] ?? self::SLEEP_ON_ERROR;
6264
}
6365

6466
/** {@inheritdoc} */

0 commit comments

Comments
 (0)