1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- <?php
-
- namespace Illuminate\Queue\Connectors;
-
- use Aws\Sqs\SqsClient;
- use Illuminate\Support\Arr;
- use Illuminate\Queue\SqsQueue;
-
- class SqsConnector implements ConnectorInterface
- {
- /**
- * Establish a queue connection.
- *
- * @param array $config
- * @return \Illuminate\Contracts\Queue\Queue
- */
- public function connect(array $config)
- {
- $config = $this->getDefaultConfiguration($config);
-
- if ($config['key'] && $config['secret']) {
- $config['credentials'] = Arr::only($config, ['key', 'secret']);
- }
-
- return new SqsQueue(
- new SqsClient($config), $config['queue'], $config['prefix'] ?? ''
- );
- }
-
- /**
- * Get the default configuration for SQS.
- *
- * @param array $config
- * @return array
- */
- protected function getDefaultConfiguration(array $config)
- {
- return array_merge([
- 'version' => 'latest',
- 'http' => [
- 'timeout' => 60,
- 'connect_timeout' => 60,
- ],
- ], $config);
- }
- }
|