Skip to content

Commit

Permalink
Merge pull request #353 from gitis/issue-352_allow_custom_aws_endpoin…
Browse files Browse the repository at this point in the history
…t_configuration

Added endpoint configuration and updated the tests
  • Loading branch information
makasim authored Feb 5, 2018
2 parents f8991bc + 7ce0092 commit 1060a06
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/sqs/SqsConnectionFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class SqsConnectionFactory implements PsrConnectionFactory
* 'retries' => 3, - (int, default=int(3)) Configures the maximum number of allowed retries for a client (pass 0 to disable retries).
* 'version' => '2012-11-05', - (string, required) The version of the webservice to utilize
* 'lazy' => true, - Enable lazy connection (boolean)
* 'endpoint' => null - (string, default=null) The full URI of the webservice. This is only required when connecting to a custom endpoint e.g. localstack
* ].
*
* or
Expand Down Expand Up @@ -93,6 +94,10 @@ private function establishConnection()
'region' => $this->config['region'],
];

if (isset($this->config['endpoint'])) {
$config['endpoint'] = $this->config['endpoint'];
}

if ($this->config['key'] && $this->config['secret']) {
$config['credentials'] = [
'key' => $this->config['key'],
Expand Down Expand Up @@ -151,6 +156,7 @@ private function defaultConfig()
'retries' => 3,
'version' => '2012-11-05',
'lazy' => true,
'endpoint' => null,
];
}
}
26 changes: 26 additions & 0 deletions pkg/sqs/Tests/SqsConnectionFactoryConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public static function provideConfigs()
'retries' => 3,
'version' => '2012-11-05',
'lazy' => true,
'endpoint' => null,
],
];

Expand All @@ -75,6 +76,7 @@ public static function provideConfigs()
'retries' => 3,
'version' => '2012-11-05',
'lazy' => true,
'endpoint' => null,
],
];

Expand All @@ -88,6 +90,7 @@ public static function provideConfigs()
'retries' => 3,
'version' => '2012-11-05',
'lazy' => true,
'endpoint' => null,
],
];

Expand All @@ -101,6 +104,7 @@ public static function provideConfigs()
'retries' => 3,
'version' => '2012-11-05',
'lazy' => false,
'endpoint' => null,
],
];

Expand All @@ -114,6 +118,7 @@ public static function provideConfigs()
'retries' => 3,
'version' => '2012-11-05',
'lazy' => false,
'endpoint' => null,
],
];

Expand All @@ -127,6 +132,27 @@ public static function provideConfigs()
'retries' => 3,
'version' => '2012-11-05',
'lazy' => false,
'endpoint' => null,
],
];

yield [
[
'key' => 'theKey',
'secret' => 'theSecret',
'token' => 'theToken',
'lazy' => false,
'endpoint' => 'http://localstack:1111',
],
[
'key' => 'theKey',
'secret' => 'theSecret',
'token' => 'theToken',
'region' => null,
'retries' => 3,
'version' => '2012-11-05',
'lazy' => false,
'endpoint' => 'http://localstack:1111',
],
];
}
Expand Down
2 changes: 2 additions & 0 deletions pkg/sqs/Tests/SqsConnectionFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public function testCouldBeConstructedWithEmptyConfiguration()
'region' => null,
'retries' => 3,
'version' => '2012-11-05',
'endpoint' => null,
], 'config', $factory);
}

Expand All @@ -43,6 +44,7 @@ public function testCouldBeConstructedWithCustomConfiguration()
'region' => null,
'retries' => 3,
'version' => '2012-11-05',
'endpoint' => null,
], 'config', $factory);
}

Expand Down

0 comments on commit 1060a06

Please sign in to comment.