@@ -79,9 +79,9 @@ discard block |
||
79 | 79 | ->with(self::class, 'bar', []) |
80 | 80 | ->willThrowException(new TestRetryException()); |
81 | 81 | |
82 | - try { |
|
82 | + try{ |
|
83 | 83 | $this->interceptor->process(self::class, 'bar', [], $this->core); |
84 | - } catch (RetryException $e) { |
|
84 | + }catch (RetryException $e){ |
|
85 | 85 | $this->assertSame(1, $e->getOptions()->getDelay()); |
86 | 86 | $this->assertSame(['attempts' => ['1']], $e->getOptions()->getHeaders()); |
87 | 87 | } |
@@ -99,9 +99,9 @@ discard block |
||
99 | 99 | retryPolicy: new \Spiral\Queue\RetryPolicy(maxAttempts: 2, delay: 4) |
100 | 100 | )); |
101 | 101 | |
102 | - try { |
|
102 | + try{ |
|
103 | 103 | $this->interceptor->process(self::class, 'bar', [], $this->core); |
104 | - } catch (RetryException $e) { |
|
104 | + }catch (RetryException $e){ |
|
105 | 105 | $this->assertSame(4, $e->getOptions()->getDelay()); |
106 | 106 | $this->assertSame(['attempts' => ['1']], $e->getOptions()->getHeaders()); |
107 | 107 | } |
@@ -119,14 +119,14 @@ discard block |
||
119 | 119 | ->with(self::class, 'bar', ['headers' => ['attempts' => ['1']]]) |
120 | 120 | ->willThrowException(new TestRetryException()); |
121 | 121 | |
122 | - try { |
|
122 | + try{ |
|
123 | 123 | $this->interceptor->process( |
124 | 124 | self::class, |
125 | 125 | 'bar', |
126 | 126 | ['headers' => ['attempts' => ['1']]], |
127 | 127 | $this->core |
128 | 128 | ); |
129 | - } catch (RetryException $e) { |
|
129 | + }catch (RetryException $e){ |
|
130 | 130 | $this->assertSame(8, $e->getOptions()->getDelay()); |
131 | 131 | $this->assertSame(['attempts' => ['2']], $e->getOptions()->getHeaders()); |
132 | 132 | } |
@@ -146,14 +146,14 @@ discard block |
||
146 | 146 | retryPolicy: new \Spiral\Queue\RetryPolicy(maxAttempts: 3, delay: 4, multiplier: 2) |
147 | 147 | )); |
148 | 148 | |
149 | - try { |
|
149 | + try{ |
|
150 | 150 | $this->interceptor->process( |
151 | 151 | self::class, |
152 | 152 | 'bar', |
153 | 153 | ['headers' => ['attempts' => ['1']]], |
154 | 154 | $this->core |
155 | 155 | ); |
156 | - } catch (RetryException $e) { |
|
156 | + }catch (RetryException $e){ |
|
157 | 157 | $this->assertSame(8, $e->getOptions()->getDelay()); |
158 | 158 | $this->assertSame(['attempts' => ['2']], $e->getOptions()->getHeaders()); |
159 | 159 | } |
@@ -175,14 +175,14 @@ discard block |
||
175 | 175 | ) |
176 | 176 | )); |
177 | 177 | |
178 | - try { |
|
178 | + try{ |
|
179 | 179 | $this->interceptor->process( |
180 | 180 | self::class, |
181 | 181 | 'bar', |
182 | 182 | ['headers' => ['attempts' => ['1']]], |
183 | 183 | $this->core |
184 | 184 | ); |
185 | - } catch (RetryException $e) { |
|
185 | + }catch (RetryException $e){ |
|
186 | 186 | $this->assertSame(8, $e->getOptions()->getDelay()); |
187 | 187 | $this->assertSame(['attempts' => ['2']], $e->getOptions()->getHeaders()); |
188 | 188 | } |
@@ -79,9 +79,12 @@ discard block |
||
79 | 79 | ->with(self::class, 'bar', []) |
80 | 80 | ->willThrowException(new TestRetryException()); |
81 | 81 | |
82 | - try { |
|
82 | + try |
|
83 | + { |
|
83 | 84 | $this->interceptor->process(self::class, 'bar', [], $this->core); |
84 | - } catch (RetryException $e) { |
|
85 | + } |
|
86 | + catch (RetryException $e) |
|
87 | + { |
|
85 | 88 | $this->assertSame(1, $e->getOptions()->getDelay()); |
86 | 89 | $this->assertSame(['attempts' => ['1']], $e->getOptions()->getHeaders()); |
87 | 90 | } |
@@ -99,9 +102,12 @@ discard block |
||
99 | 102 | retryPolicy: new \Spiral\Queue\RetryPolicy(maxAttempts: 2, delay: 4) |
100 | 103 | )); |
101 | 104 | |
102 | - try { |
|
105 | + try |
|
106 | + { |
|
103 | 107 | $this->interceptor->process(self::class, 'bar', [], $this->core); |
104 | - } catch (RetryException $e) { |
|
108 | + } |
|
109 | + catch (RetryException $e) |
|
110 | + { |
|
105 | 111 | $this->assertSame(4, $e->getOptions()->getDelay()); |
106 | 112 | $this->assertSame(['attempts' => ['1']], $e->getOptions()->getHeaders()); |
107 | 113 | } |
@@ -119,14 +125,17 @@ discard block |
||
119 | 125 | ->with(self::class, 'bar', ['headers' => ['attempts' => ['1']]]) |
120 | 126 | ->willThrowException(new TestRetryException()); |
121 | 127 | |
122 | - try { |
|
128 | + try |
|
129 | + { |
|
123 | 130 | $this->interceptor->process( |
124 | 131 | self::class, |
125 | 132 | 'bar', |
126 | 133 | ['headers' => ['attempts' => ['1']]], |
127 | 134 | $this->core |
128 | 135 | ); |
129 | - } catch (RetryException $e) { |
|
136 | + } |
|
137 | + catch (RetryException $e) |
|
138 | + { |
|
130 | 139 | $this->assertSame(8, $e->getOptions()->getDelay()); |
131 | 140 | $this->assertSame(['attempts' => ['2']], $e->getOptions()->getHeaders()); |
132 | 141 | } |
@@ -146,14 +155,17 @@ discard block |
||
146 | 155 | retryPolicy: new \Spiral\Queue\RetryPolicy(maxAttempts: 3, delay: 4, multiplier: 2) |
147 | 156 | )); |
148 | 157 | |
149 | - try { |
|
158 | + try |
|
159 | + { |
|
150 | 160 | $this->interceptor->process( |
151 | 161 | self::class, |
152 | 162 | 'bar', |
153 | 163 | ['headers' => ['attempts' => ['1']]], |
154 | 164 | $this->core |
155 | 165 | ); |
156 | - } catch (RetryException $e) { |
|
166 | + } |
|
167 | + catch (RetryException $e) |
|
168 | + { |
|
157 | 169 | $this->assertSame(8, $e->getOptions()->getDelay()); |
158 | 170 | $this->assertSame(['attempts' => ['2']], $e->getOptions()->getHeaders()); |
159 | 171 | } |
@@ -175,14 +187,17 @@ discard block |
||
175 | 187 | ) |
176 | 188 | )); |
177 | 189 | |
178 | - try { |
|
190 | + try |
|
191 | + { |
|
179 | 192 | $this->interceptor->process( |
180 | 193 | self::class, |
181 | 194 | 'bar', |
182 | 195 | ['headers' => ['attempts' => ['1']]], |
183 | 196 | $this->core |
184 | 197 | ); |
185 | - } catch (RetryException $e) { |
|
198 | + } |
|
199 | + catch (RetryException $e) |
|
200 | + { |
|
186 | 201 | $this->assertSame(8, $e->getOptions()->getDelay()); |
187 | 202 | $this->assertSame(['attempts' => ['2']], $e->getOptions()->getHeaders()); |
188 | 203 | } |
@@ -18,24 +18,24 @@ 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 | $policy = $this->getRetryPolicy($e, new \ReflectionClass($controller)); |
30 | 30 | |
31 | - if ($policy === null) { |
|
31 | + if ($policy === null){ |
|
32 | 32 | throw $e; |
33 | 33 | } |
34 | 34 | |
35 | 35 | $headers = $parameters['headers'] ?? []; |
36 | 36 | $attempts = (int)($headers['attempts'][0] ?? 0); |
37 | 37 | |
38 | - if ($policy->isRetryable($e, $attempts) === false) { |
|
38 | + if ($policy->isRetryable($e, $attempts) === false){ |
|
39 | 39 | throw $e; |
40 | 40 | } |
41 | 41 | |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | { |
53 | 53 | $attribute = $this->reader->firstClassMetadata($handler, Attribute::class); |
54 | 54 | |
55 | - if ($exception instanceof JobException && $exception->getPrevious() !== null) { |
|
55 | + if ($exception instanceof JobException && $exception->getPrevious() !== null){ |
|
56 | 56 | $exception = $exception->getPrevious(); |
57 | 57 | } |
58 | 58 |
@@ -23,19 +23,24 @@ discard block |
||
23 | 23 | |
24 | 24 | public function process(string $controller, string $action, array $parameters, CoreInterface $core): mixed |
25 | 25 | { |
26 | - try { |
|
26 | + try |
|
27 | + { |
|
27 | 28 | return $core->callAction($controller, $action, $parameters); |
28 | - } catch (\Throwable $e) { |
|
29 | + } |
|
30 | + catch (\Throwable $e) |
|
31 | + { |
|
29 | 32 | $policy = $this->getRetryPolicy($e, new \ReflectionClass($controller)); |
30 | 33 | |
31 | - if ($policy === null) { |
|
34 | + if ($policy === null) |
|
35 | + { |
|
32 | 36 | throw $e; |
33 | 37 | } |
34 | 38 | |
35 | 39 | $headers = $parameters['headers'] ?? []; |
36 | 40 | $attempts = (int)($headers['attempts'][0] ?? 0); |
37 | 41 | |
38 | - if ($policy->isRetryable($e, $attempts) === false) { |
|
42 | + if ($policy->isRetryable($e, $attempts) === false) |
|
43 | + { |
|
39 | 44 | throw $e; |
40 | 45 | } |
41 | 46 | |
@@ -52,7 +57,8 @@ discard block |
||
52 | 57 | { |
53 | 58 | $attribute = $this->reader->firstClassMetadata($handler, Attribute::class); |
54 | 59 | |
55 | - if ($exception instanceof JobException && $exception->getPrevious() !== null) { |
|
60 | + if ($exception instanceof JobException && $exception->getPrevious() !== null) |
|
61 | + { |
|
56 | 62 | $exception = $exception->getPrevious(); |
57 | 63 | } |
58 | 64 |