File tree 4 files changed +28
-4
lines changed
enqueue-bundle/Tests/Functional
4 files changed +28
-4
lines changed Original file line number Diff line number Diff line change @@ -33,3 +33,14 @@ services:
33
33
public : true
34
34
tags :
35
35
- { name: 'enqueue.client.processor' }
36
+
37
+ test.sqs_client :
38
+ public : true
39
+ class : Aws\Sqs\SqsClient
40
+ arguments :
41
+ -
42
+ region : ' %env(AWS_SQS_REGION)%'
43
+ version : ' 2012-11-05'
44
+ credentials :
45
+ key : ' %env(AWS_SQS_KEY)%'
46
+ secret : ' %env(AWS_SQS_SECRET)%'
Original file line number Diff line number Diff line change @@ -210,7 +210,7 @@ public function provideEnqueueConfigs()
210
210
'transport ' => [
211
211
'default ' => 'sqs ' ,
212
212
'sqs ' => [
213
- 'client ' => '@Aws\Sqs\SqsClient ' ,
213
+ 'client ' => 'test.sqs_client ' ,
214
214
],
215
215
],
216
216
]];
Original file line number Diff line number Diff line change @@ -39,7 +39,10 @@ class SqsConnectionFactory implements PsrConnectionFactory
39
39
public function __construct ($ config = 'sqs: ' )
40
40
{
41
41
if ($ config instanceof SqsClient) {
42
- return $ this ->client = $ config ;
42
+ $ this ->client = $ config ;
43
+ $ this ->config = $ this ->defaultConfig ();
44
+
45
+ return ;
43
46
} elseif (empty ($ config ) || 'sqs: ' === $ config ) {
44
47
$ config = [];
45
48
} elseif (is_string ($ config )) {
Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ public function addConfiguration(ArrayNodeDefinition $builder)
38
38
->scalarNode ('key ' )->defaultNull ()->end ()
39
39
->scalarNode ('secret ' )->defaultNull ()->end ()
40
40
->scalarNode ('token ' )->defaultNull ()->end ()
41
- ->scalarNode ('region ' )->isRequired ()-> end ()
41
+ ->scalarNode ('region ' )->end ()
42
42
->integerNode ('retries ' )->defaultValue (3 )->end ()
43
43
->scalarNode ('version ' )->cannotBeEmpty ()->defaultValue ('2012-11-05 ' )->end ()
44
44
->booleanNode ('lazy ' )
@@ -54,8 +54,18 @@ public function addConfiguration(ArrayNodeDefinition $builder)
54
54
*/
55
55
public function createConnectionFactory (ContainerBuilder $ container , array $ config )
56
56
{
57
+ if (empty ($ config ['client ' ]) && empty ($ config ['region ' ])) {
58
+ throw new RuntimeException ('Either "client" or "region" must be provided to SQS in Enqueue configuration ' );
59
+ }
60
+
61
+ $ arguments = $ config ;
62
+
63
+ if (!empty ($ config ['client ' ])) {
64
+ $ arguments = new Reference ($ config ['client ' ]);
65
+ }
66
+
57
67
$ factory = new Definition (SqsConnectionFactory::class);
58
- $ factory ->setArguments ([$ config ]);
68
+ $ factory ->setArguments ([$ arguments ]);
59
69
60
70
$ factoryId = sprintf ('enqueue.transport.%s.connection_factory ' , $ this ->getName ());
61
71
$ container ->setDefinition ($ factoryId , $ factory );
You can’t perform that action at this time.
0 commit comments