File tree Expand file tree Collapse file tree 5 files changed +41
-9
lines changed Expand file tree Collapse file tree 5 files changed +41
-9
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Kiboko \Component \Flow \RabbitMQ ;
4+
5+ use Bunny \Client ;
6+
7+ class ClientMiddleware
8+ {
9+ private static ?Client $ instance = null ;
10+
11+ public static function getInstance (
12+ string $ host ,
13+ string $ vhost ,
14+ ?string $ user ,
15+ ?string $ password ,
16+ ?int $ port = null ,
17+ ): Client {
18+ if (null === self ::$ instance ) {
19+ self ::$ instance = new Client ([
20+ 'host ' => $ host ,
21+ 'port ' => $ port ,
22+ 'vhost ' => $ vhost ,
23+ 'user ' => $ user ,
24+ 'password ' => $ password ,
25+ ]);
26+
27+ self ::$ instance ->connect ();
28+ }
29+
30+ return self ::$ instance ;
31+ }
32+ }
Original file line number Diff line number Diff line change 1414 private Channel $ channel ;
1515
1616 public function __construct (
17- private Client $ connection ,
17+ private Client $ client ,
1818 private string $ topic ,
1919 ) {
20- $ this ->channel = $ this ->connection ->channel ();
20+ $ this ->channel = $ this ->client ->channel ();
2121
2222 $ this ->channel ->queueDeclare (
2323 queue: $ this ->topic ,
Original file line number Diff line number Diff line change 1515 private Channel $ channel ;
1616
1717 public function __construct (
18- private Client $ connection ,
18+ private Client $ client ,
1919 private string $ topic ,
2020 private ?string $ exchange = null ,
2121 ) {
22- $ this ->channel = $ this ->connection ->channel ();
22+ $ this ->channel = $ this ->client ->channel ();
2323
2424 $ this ->channel ->queueDeclare (
2525 queue: $ this ->topic ,
Original file line number Diff line number Diff line change 1414 private Channel $ channel ;
1515
1616 public function __construct (
17- private Client $ connection ,
17+ private Client $ client ,
1818 private string $ stepUuid ,
1919 private string $ topic ,
2020 private ?string $ exchange = null ,
2121 ) {
22- $ this ->channel = $ this ->connection ->channel ();
22+ $ this ->channel = $ this ->client ->channel ();
2323 $ this ->channel ->queueDeclare (
2424 queue: $ this ->topic ,
2525 passive: false ,
@@ -32,7 +32,7 @@ public function __construct(
3232 public function teardown (): void
3333 {
3434 $ this ->channel ->close ();
35- $ this ->connection ->stop ();
35+ $ this ->client ->stop ();
3636 }
3737
3838 public static function withoutAuthentication (
Original file line number Diff line number Diff line change @@ -17,12 +17,12 @@ class StateManager
1717 private readonly Channel $ channel ;
1818
1919 public function __construct (
20- private readonly Client $ connection ,
20+ private readonly Client $ client ,
2121 private readonly string $ topic ,
2222 private readonly int $ lineThreshold = 1000 ,
2323 private readonly ?string $ exchange = null ,
2424 ) {
25- $ this ->channel = $ this ->connection ->channel ();
25+ $ this ->channel = $ this ->client ->channel ();
2626
2727 $ this ->channel ->queueDeclare (
2828 queue: $ this ->topic ,
You can’t perform that action at this time.
0 commit comments