@@ -78,9 +78,9 @@ discard block |
||
78 | 78 | retryPolicy: new \Spiral\Queue\RetryPolicy(maxAttempts: 2, delay: 4) |
79 | 79 | )); |
80 | 80 | |
81 | - try { |
|
81 | + try{ |
|
82 | 82 | $this->interceptor->process('foo-job', 'bar', [], $this->core); |
83 | - } catch (RetryException $e) { |
|
83 | + }catch (RetryException $e){ |
|
84 | 84 | $this->assertSame(4, $e->getOptions()->getDelay()); |
85 | 85 | $this->assertSame(['attempts' => ['1']], $e->getOptions()->getHeaders()); |
86 | 86 | } |
@@ -111,9 +111,9 @@ discard block |
||
111 | 111 | ->with(self::class, 'bar', []) |
112 | 112 | ->willThrowException(new TestRetryException()); |
113 | 113 | |
114 | - try { |
|
114 | + try{ |
|
115 | 115 | $this->interceptor->process(self::class, 'bar', [], $this->core); |
116 | - } catch (RetryException $e) { |
|
116 | + }catch (RetryException $e){ |
|
117 | 117 | $this->assertSame(1, $e->getOptions()->getDelay()); |
118 | 118 | $this->assertSame(['attempts' => ['1']], $e->getOptions()->getHeaders()); |
119 | 119 | } |
@@ -131,9 +131,9 @@ discard block |
||
131 | 131 | retryPolicy: new \Spiral\Queue\RetryPolicy(maxAttempts: 2, delay: 4) |
132 | 132 | )); |
133 | 133 | |
134 | - try { |
|
134 | + try{ |
|
135 | 135 | $this->interceptor->process(self::class, 'bar', [], $this->core); |
136 | - } catch (RetryException $e) { |
|
136 | + }catch (RetryException $e){ |
|
137 | 137 | $this->assertSame(4, $e->getOptions()->getDelay()); |
138 | 138 | $this->assertSame(['attempts' => ['1']], $e->getOptions()->getHeaders()); |
139 | 139 | } |
@@ -151,14 +151,14 @@ discard block |
||
151 | 151 | ->with(self::class, 'bar', ['headers' => ['attempts' => ['1']]]) |
152 | 152 | ->willThrowException(new TestRetryException()); |
153 | 153 | |
154 | - try { |
|
154 | + try{ |
|
155 | 155 | $this->interceptor->process( |
156 | 156 | self::class, |
157 | 157 | 'bar', |
158 | 158 | ['headers' => ['attempts' => ['1']]], |
159 | 159 | $this->core |
160 | 160 | ); |
161 | - } catch (RetryException $e) { |
|
161 | + }catch (RetryException $e){ |
|
162 | 162 | $this->assertSame(8, $e->getOptions()->getDelay()); |
163 | 163 | $this->assertSame(['attempts' => ['2']], $e->getOptions()->getHeaders()); |
164 | 164 | } |
@@ -178,14 +178,14 @@ discard block |
||
178 | 178 | retryPolicy: new \Spiral\Queue\RetryPolicy(maxAttempts: 3, delay: 4, multiplier: 2) |
179 | 179 | )); |
180 | 180 | |
181 | - try { |
|
181 | + try{ |
|
182 | 182 | $this->interceptor->process( |
183 | 183 | self::class, |
184 | 184 | 'bar', |
185 | 185 | ['headers' => ['attempts' => ['1']]], |
186 | 186 | $this->core |
187 | 187 | ); |
188 | - } catch (RetryException $e) { |
|
188 | + }catch (RetryException $e){ |
|
189 | 189 | $this->assertSame(8, $e->getOptions()->getDelay()); |
190 | 190 | $this->assertSame(['attempts' => ['2']], $e->getOptions()->getHeaders()); |
191 | 191 | } |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | ->method('callAction') |
203 | 203 | ->with(self::class, 'bar', ['headers' => ['attempts' => ['1']]]) |
204 | 204 | ->willThrowException(new TestRetryException( |
205 | - retryPolicy: new class implements RetryPolicyInterface { |
|
205 | + retryPolicy: new class implements RetryPolicyInterface{ |
|
206 | 206 | public function isRetryable(\Throwable $exception, int $attempts = 0): bool |
207 | 207 | { |
208 | 208 | return true; |
@@ -215,14 +215,14 @@ discard block |
||
215 | 215 | } |
216 | 216 | )); |
217 | 217 | |
218 | - try { |
|
218 | + try{ |
|
219 | 219 | $this->interceptor->process( |
220 | 220 | self::class, |
221 | 221 | 'bar', |
222 | 222 | ['headers' => ['attempts' => ['1']]], |
223 | 223 | $this->core |
224 | 224 | ); |
225 | - } catch (RetryException $e) { |
|
225 | + }catch (RetryException $e){ |
|
226 | 226 | $this->assertSame(5, $e->getOptions()->getDelay()); |
227 | 227 | $this->assertSame(['attempts' => ['2']], $e->getOptions()->getHeaders()); |
228 | 228 | } |
@@ -244,14 +244,14 @@ discard block |
||
244 | 244 | ) |
245 | 245 | )); |
246 | 246 | |
247 | - try { |
|
247 | + try{ |
|
248 | 248 | $this->interceptor->process( |
249 | 249 | self::class, |
250 | 250 | 'bar', |
251 | 251 | ['headers' => ['attempts' => ['1']]], |
252 | 252 | $this->core |
253 | 253 | ); |
254 | - } catch (RetryException $e) { |
|
254 | + }catch (RetryException $e){ |
|
255 | 255 | $this->assertSame(8, $e->getOptions()->getDelay()); |
256 | 256 | $this->assertSame(['attempts' => ['2']], $e->getOptions()->getHeaders()); |
257 | 257 | } |
@@ -18,27 +18,27 @@ discard block |
||
18 | 18 | { |
19 | 19 | public function __construct( |
20 | 20 | private readonly ReaderInterface $reader, |
21 | - ) { |
|
21 | + ){ |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | public function process(string $controller, string $action, array $parameters, CoreInterface $core): mixed |
25 | 25 | { |
26 | - try { |
|
26 | + try{ |
|
27 | 27 | return $core->callAction($controller, $action, $parameters); |
28 | - } catch (\Throwable $e) { |
|
28 | + }catch (\Throwable $e){ |
|
29 | 29 | // In some cases job handler class may not exist or be just a string. |
30 | 30 | // In this case we can't get retry policy from it. |
31 | 31 | $class = \class_exists($controller) ? new \ReflectionClass($controller) : null; |
32 | 32 | $policy = $this->getRetryPolicy($e, $class); |
33 | 33 | |
34 | - if ($policy === null) { |
|
34 | + if ($policy === null){ |
|
35 | 35 | throw $e; |
36 | 36 | } |
37 | 37 | |
38 | 38 | $headers = $parameters['headers'] ?? []; |
39 | 39 | $attempts = (int)($headers['attempts'][0] ?? 0); |
40 | 40 | |
41 | - if ($policy->isRetryable($e, $attempts) === false) { |
|
41 | + if ($policy->isRetryable($e, $attempts) === false){ |
|
42 | 42 | throw $e; |
43 | 43 | } |
44 | 44 | |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | ? $this->reader->firstClassMetadata($handler, Attribute::class) |
58 | 58 | : null; |
59 | 59 | |
60 | - if ($exception instanceof JobException && $exception->getPrevious() !== null) { |
|
60 | + if ($exception instanceof JobException && $exception->getPrevious() !== null){ |
|
61 | 61 | $exception = $exception->getPrevious(); |
62 | 62 | } |
63 | 63 |