Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 1441
Línea 62... Línea 62...
62
{
62
{
63
    public function __construct(array $config)
63
    public function __construct(array $config)
64
    {
64
    {
65
        parent::__construct($config);
65
        parent::__construct($config);
66
        $list = $this->getHandlerList();
66
        $list = $this->getHandlerList();
67
        $list->appendBuild($this->queueUrl(), 'sqs.queue_url');
-
 
68
        $list->appendSign($this->validateMd5(), 'sqs.md5');
67
        $list->appendSign($this->validateMd5(), 'sqs.md5');
69
    }
68
    }
Línea 70... Línea 69...
70
 
69
 
71
    /**
70
    /**
Línea 92... Línea 91...
92
        }
91
        }
93
        return $queueArn;
92
        return $queueArn;
94
    }
93
    }
Línea 95... Línea 94...
95
 
94
 
96
    /**
-
 
97
     * Moves the URI of the queue to the URI in the input parameter.
-
 
98
     *
-
 
99
     * @return callable
-
 
100
     */
-
 
101
    private function queueUrl()
-
 
102
    {
-
 
103
        return static function (callable $handler) {
-
 
104
            return function (
-
 
105
                CommandInterface $c,
-
 
106
                RequestInterface $r = null
-
 
107
            ) use ($handler) {
-
 
108
                if ($c->hasParam('QueueUrl')) {
-
 
109
                    $r = $r->withUri(UriResolver::resolve(
-
 
110
                        $r->getUri(),
-
 
111
                        new Uri($c['QueueUrl'])
-
 
112
                    ));
-
 
113
                }
-
 
114
                return $handler($c, $r);
-
 
115
            };
-
 
116
        };
-
 
117
    }
-
 
118
 
-
 
119
    /**
95
    /**
120
     * Calculates the expected md5 hash of message attributes according to the encoding
96
     * Calculates the expected md5 hash of message attributes according to the encoding
121
     * scheme detailed in SQS documentation.
97
     * scheme detailed in SQS documentation.
122
     *
98
     *
123
     * @param array $message Message containing attributes for validation.
99
     * @param array $message Message containing attributes for validation.
Línea 191... Línea 167...
191
    private function validateMd5()
167
    private function validateMd5()
192
    {
168
    {
193
        return static function (callable $handler) {
169
        return static function (callable $handler) {
194
            return function (
170
            return function (
195
                CommandInterface $c,
171
                CommandInterface $c,
196
                RequestInterface $r = null
172
                ?RequestInterface $r = null
197
            ) use ($handler) {
173
            ) use ($handler) {
198
                if ($c->getName() !== 'ReceiveMessage') {
174
                if ($c->getName() !== 'ReceiveMessage') {
199
                    return $handler($c, $r);
175
                    return $handler($c, $r);
200
                }
176
                }
Línea 237... Línea 213...
237
                                                'code' => 'ClientChecksumMismatch',
213
                                                'code' => 'ClientChecksumMismatch',
238
                                                'request' => $r
214
                                                'request' => $r
239
                                            ]
215
                                            ]
240
                                        );
216
                                        );
241
                                    }
217
                                    }
242
                                } else if (isset($msg['MessageAttributes'])) {
218
                                } else if (!empty($msg['MessageAttributes'])) {
243
                                    throw new SqsException(
219
                                    throw new SqsException(
244
                                        sprintf(
220
                                        sprintf(
245
                                            'No Attribute MD5 found. Expected %s',
221
                                            'No Attribute MD5 found. Expected %s',
246
                                            self::calculateMessageAttributesMd5($msg)
222
                                            self::calculateMessageAttributesMd5($msg)
247
                                        ),
223
                                        ),