Skip to content

Commit be7a040

Browse files
committed
review fixes
1 parent 6d5172c commit be7a040

File tree

3 files changed

+20
-18
lines changed

3 files changed

+20
-18
lines changed

src/VladimirYuldashev/LaravelQueueRabbitMQ/LaravelQueueRabbitMQServiceProvider.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace VladimirYuldashev\LaravelQueueRabbitMQ;
44

5+
use Illuminate\Queue\QueueManager;
56
use Illuminate\Support\ServiceProvider;
67
use VladimirYuldashev\LaravelQueueRabbitMQ\Queue\Connectors\RabbitMQConnector;
78

@@ -26,15 +27,16 @@ public function register()
2627
*/
2728
public function boot()
2829
{
29-
$appQueue = app('queue');
30-
$rabbitMQConnector = new RabbitMQConnector();
30+
/** @var QueueManager $queue */
31+
$queue = $this->app['queue'];
32+
$connector = new RabbitMQConnector;
3133

32-
$appQueue->stopping(function () use ($rabbitMQConnector) {
33-
$rabbitMQConnector->getConnection()->close();
34+
$queue->stopping(function () use ($connector) {
35+
$connector->connection()->close();
3436
});
3537

36-
$appQueue->addConnector('rabbitmq', function () use ($rabbitMQConnector) {
37-
return $rabbitMQConnector;
38+
$queue->addConnector('rabbitmq', function () use ($connector) {
39+
return $connector;
3840
});
3941
}
4042
}

src/VladimirYuldashev/LaravelQueueRabbitMQ/Queue/Connectors/RabbitMQConnector.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88

99
class RabbitMQConnector implements ConnectorInterface
1010
{
11+
12+
/** @var AMQPStreamConnection */
13+
private $connection;
14+
1115
/**
1216
* Establish a queue connection.
1317
*
@@ -18,7 +22,7 @@ class RabbitMQConnector implements ConnectorInterface
1822
public function connect(array $config)
1923
{
2024
// create connection with AMQP
21-
$connection = new AMQPStreamConnection(
25+
$this->connection = new AMQPStreamConnection(
2226
$config['host'],
2327
$config['port'],
2428
$config['login'],
@@ -27,8 +31,14 @@ public function connect(array $config)
2731
);
2832

2933
return new RabbitMQQueue(
30-
$connection,
34+
$this->connection,
3135
$config
3236
);
3337
}
38+
39+
public function connection()
40+
{
41+
return $this->connection;
42+
}
43+
3444
}

src/VladimirYuldashev/LaravelQueueRabbitMQ/Queue/RabbitMQQueue.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -330,14 +330,4 @@ private function reportConnectionError($action, Exception $e)
330330
sleep($this->sleepOnError);
331331
}
332332

333-
/**
334-
* Return rabbit connection layer
335-
*
336-
* @return AMQPStreamConnection
337-
*/
338-
public function getConnection()
339-
{
340-
return $this->connection;
341-
}
342-
343333
}

0 commit comments

Comments
 (0)