Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added endpoint configuration and updated the tests #353

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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