Skip to content

Commit 1060a06

Browse files
authored
Merge pull request #353 from gitis/issue-352_allow_custom_aws_endpoint_configuration
Added endpoint configuration and updated the tests
2 parents f8991bc + 7ce0092 commit 1060a06

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

pkg/sqs/SqsConnectionFactory.php

+6
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class SqsConnectionFactory implements PsrConnectionFactory
2626
* 'retries' => 3, - (int, default=int(3)) Configures the maximum number of allowed retries for a client (pass 0 to disable retries).
2727
* 'version' => '2012-11-05', - (string, required) The version of the webservice to utilize
2828
* 'lazy' => true, - Enable lazy connection (boolean)
29+
* 'endpoint' => null - (string, default=null) The full URI of the webservice. This is only required when connecting to a custom endpoint e.g. localstack
2930
* ].
3031
*
3132
* or
@@ -93,6 +94,10 @@ private function establishConnection()
9394
'region' => $this->config['region'],
9495
];
9596

97+
if (isset($this->config['endpoint'])) {
98+
$config['endpoint'] = $this->config['endpoint'];
99+
}
100+
96101
if ($this->config['key'] && $this->config['secret']) {
97102
$config['credentials'] = [
98103
'key' => $this->config['key'],
@@ -151,6 +156,7 @@ private function defaultConfig()
151156
'retries' => 3,
152157
'version' => '2012-11-05',
153158
'lazy' => true,
159+
'endpoint' => null,
154160
];
155161
}
156162
}

pkg/sqs/Tests/SqsConnectionFactoryConfigTest.php

+26
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ public static function provideConfigs()
6262
'retries' => 3,
6363
'version' => '2012-11-05',
6464
'lazy' => true,
65+
'endpoint' => null,
6566
],
6667
];
6768

@@ -75,6 +76,7 @@ public static function provideConfigs()
7576
'retries' => 3,
7677
'version' => '2012-11-05',
7778
'lazy' => true,
79+
'endpoint' => null,
7880
],
7981
];
8082

@@ -88,6 +90,7 @@ public static function provideConfigs()
8890
'retries' => 3,
8991
'version' => '2012-11-05',
9092
'lazy' => true,
93+
'endpoint' => null,
9194
],
9295
];
9396

@@ -101,6 +104,7 @@ public static function provideConfigs()
101104
'retries' => 3,
102105
'version' => '2012-11-05',
103106
'lazy' => false,
107+
'endpoint' => null,
104108
],
105109
];
106110

@@ -114,6 +118,7 @@ public static function provideConfigs()
114118
'retries' => 3,
115119
'version' => '2012-11-05',
116120
'lazy' => false,
121+
'endpoint' => null,
117122
],
118123
];
119124

@@ -127,6 +132,27 @@ public static function provideConfigs()
127132
'retries' => 3,
128133
'version' => '2012-11-05',
129134
'lazy' => false,
135+
'endpoint' => null,
136+
],
137+
];
138+
139+
yield [
140+
[
141+
'key' => 'theKey',
142+
'secret' => 'theSecret',
143+
'token' => 'theToken',
144+
'lazy' => false,
145+
'endpoint' => 'http://localstack:1111',
146+
],
147+
[
148+
'key' => 'theKey',
149+
'secret' => 'theSecret',
150+
'token' => 'theToken',
151+
'region' => null,
152+
'retries' => 3,
153+
'version' => '2012-11-05',
154+
'lazy' => false,
155+
'endpoint' => 'http://localstack:1111',
130156
],
131157
];
132158
}

pkg/sqs/Tests/SqsConnectionFactoryTest.php

+2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public function testCouldBeConstructedWithEmptyConfiguration()
2828
'region' => null,
2929
'retries' => 3,
3030
'version' => '2012-11-05',
31+
'endpoint' => null,
3132
], 'config', $factory);
3233
}
3334

@@ -43,6 +44,7 @@ public function testCouldBeConstructedWithCustomConfiguration()
4344
'region' => null,
4445
'retries' => 3,
4546
'version' => '2012-11-05',
47+
'endpoint' => null,
4648
], 'config', $factory);
4749
}
4850

0 commit comments

Comments
 (0)