Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
<?php
2
 
3
namespace Illuminate\Queue\Connectors;
4
 
5
use Aws\Sqs\SqsClient;
6
use Illuminate\Queue\SqsQueue;
7
use Illuminate\Support\Arr;
8
 
9
class SqsConnector implements ConnectorInterface
10
{
11
    /**
12
     * Establish a queue connection.
13
     *
14
     * @param  array  $config
15
     * @return \Illuminate\Contracts\Queue\Queue
16
     */
17
    public function connect(array $config)
18
    {
19
        $config = $this->getDefaultConfiguration($config);
20
 
21
        if (! empty($config['key']) && ! empty($config['secret'])) {
22
            $config['credentials'] = Arr::only($config, ['key', 'secret', 'token']);
23
        }
24
 
25
        return new SqsQueue(
26
            new SqsClient(
27
                Arr::except($config, ['token'])
28
            ),
29
            $config['queue'],
30
            $config['prefix'] ?? '',
31
            $config['suffix'] ?? '',
32
            $config['after_commit'] ?? null
33
        );
34
    }
35
 
36
    /**
37
     * Get the default configuration for SQS.
38
     *
39
     * @param  array  $config
40
     * @return array
41
     */
42
    protected function getDefaultConfiguration(array $config)
43
    {
44
        return array_merge([
45
            'version' => 'latest',
46
            'http' => [
47
                'timeout' => 60,
48
                'connect_timeout' => 60,
49
            ],
50
        ], $config);
51
    }
52
}