File tree 5 files changed +41
-9
lines changed
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 14
14
private Channel $ channel ;
15
15
16
16
public function __construct (
17
- private Client $ connection ,
17
+ private Client $ client ,
18
18
private string $ topic ,
19
19
) {
20
- $ this ->channel = $ this ->connection ->channel ();
20
+ $ this ->channel = $ this ->client ->channel ();
21
21
22
22
$ this ->channel ->queueDeclare (
23
23
queue: $ this ->topic ,
Original file line number Diff line number Diff line change 15
15
private Channel $ channel ;
16
16
17
17
public function __construct (
18
- private Client $ connection ,
18
+ private Client $ client ,
19
19
private string $ topic ,
20
20
private ?string $ exchange = null ,
21
21
) {
22
- $ this ->channel = $ this ->connection ->channel ();
22
+ $ this ->channel = $ this ->client ->channel ();
23
23
24
24
$ this ->channel ->queueDeclare (
25
25
queue: $ this ->topic ,
Original file line number Diff line number Diff line change 14
14
private Channel $ channel ;
15
15
16
16
public function __construct (
17
- private Client $ connection ,
17
+ private Client $ client ,
18
18
private string $ stepUuid ,
19
19
private string $ topic ,
20
20
private ?string $ exchange = null ,
21
21
) {
22
- $ this ->channel = $ this ->connection ->channel ();
22
+ $ this ->channel = $ this ->client ->channel ();
23
23
$ this ->channel ->queueDeclare (
24
24
queue: $ this ->topic ,
25
25
passive: false ,
@@ -32,7 +32,7 @@ public function __construct(
32
32
public function teardown (): void
33
33
{
34
34
$ this ->channel ->close ();
35
- $ this ->connection ->stop ();
35
+ $ this ->client ->stop ();
36
36
}
37
37
38
38
public static function withoutAuthentication (
Original file line number Diff line number Diff line change @@ -17,12 +17,12 @@ class StateManager
17
17
private readonly Channel $ channel ;
18
18
19
19
public function __construct (
20
- private readonly Client $ connection ,
20
+ private readonly Client $ client ,
21
21
private readonly string $ topic ,
22
22
private readonly int $ lineThreshold = 1000 ,
23
23
private readonly ?string $ exchange = null ,
24
24
) {
25
- $ this ->channel = $ this ->connection ->channel ();
25
+ $ this ->channel = $ this ->client ->channel ();
26
26
27
27
$ this ->channel ->queueDeclare (
28
28
queue: $ this ->topic ,
You can’t perform that action at this time.
0 commit comments