@@ -97,9 +97,9 @@ discard block |
||
| 97 | 97 | ->with($name, 'bar', []) |
| 98 | 98 | ->willThrowException(new TestRetryException()); |
| 99 | 99 | |
| 100 | - try { |
|
| 100 | + try{ |
|
| 101 | 101 | $this->interceptor->process($name, 'bar', [], $this->core); |
| 102 | - } catch (RetryException $e) { |
|
| 102 | + }catch (RetryException $e){ |
|
| 103 | 103 | $this->assertSame(1, $e->getOptions()->getDelay()); |
| 104 | 104 | $this->assertSame(['attempts' => ['1']], $e->getOptions()->getHeaders()); |
| 105 | 105 | } |
@@ -118,9 +118,9 @@ discard block |
||
| 118 | 118 | retryPolicy: new \Spiral\Queue\RetryPolicy(maxAttempts: 2, delay: 4) |
| 119 | 119 | )); |
| 120 | 120 | |
| 121 | - try { |
|
| 121 | + try{ |
|
| 122 | 122 | $this->interceptor->process($name, 'bar', [], $this->core); |
| 123 | - } catch (RetryException $e) { |
|
| 123 | + }catch (RetryException $e){ |
|
| 124 | 124 | $this->assertSame(4, $e->getOptions()->getDelay()); |
| 125 | 125 | $this->assertSame(['attempts' => ['1']], $e->getOptions()->getHeaders()); |
| 126 | 126 | } |
@@ -139,14 +139,14 @@ discard block |
||
| 139 | 139 | ->with($name, 'bar', ['headers' => ['attempts' => ['1']]]) |
| 140 | 140 | ->willThrowException(new TestRetryException()); |
| 141 | 141 | |
| 142 | - try { |
|
| 142 | + try{ |
|
| 143 | 143 | $this->interceptor->process( |
| 144 | 144 | $name, |
| 145 | 145 | 'bar', |
| 146 | 146 | ['headers' => ['attempts' => ['1']]], |
| 147 | 147 | $this->core |
| 148 | 148 | ); |
| 149 | - } catch (RetryException $e) { |
|
| 149 | + }catch (RetryException $e){ |
|
| 150 | 150 | $this->assertSame(8, $e->getOptions()->getDelay()); |
| 151 | 151 | $this->assertSame(['attempts' => ['2']], $e->getOptions()->getHeaders()); |
| 152 | 152 | } |
@@ -167,14 +167,14 @@ discard block |
||
| 167 | 167 | retryPolicy: new \Spiral\Queue\RetryPolicy(maxAttempts: 3, delay: 4, multiplier: 2) |
| 168 | 168 | )); |
| 169 | 169 | |
| 170 | - try { |
|
| 170 | + try{ |
|
| 171 | 171 | $this->interceptor->process( |
| 172 | 172 | $name, |
| 173 | 173 | 'bar', |
| 174 | 174 | ['headers' => ['attempts' => ['1']]], |
| 175 | 175 | $this->core |
| 176 | 176 | ); |
| 177 | - } catch (RetryException $e) { |
|
| 177 | + }catch (RetryException $e){ |
|
| 178 | 178 | $this->assertSame(8, $e->getOptions()->getDelay()); |
| 179 | 179 | $this->assertSame(['attempts' => ['2']], $e->getOptions()->getHeaders()); |
| 180 | 180 | } |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | ->method('callAction') |
| 193 | 193 | ->with($name, 'bar', ['headers' => ['attempts' => ['1']]]) |
| 194 | 194 | ->willThrowException(new TestRetryException( |
| 195 | - retryPolicy: new class implements RetryPolicyInterface { |
|
| 195 | + retryPolicy: new class implements RetryPolicyInterface{ |
|
| 196 | 196 | public function isRetryable(\Throwable $exception, int $attempts = 0): bool |
| 197 | 197 | { |
| 198 | 198 | return true; |
@@ -205,14 +205,14 @@ discard block |
||
| 205 | 205 | } |
| 206 | 206 | )); |
| 207 | 207 | |
| 208 | - try { |
|
| 208 | + try{ |
|
| 209 | 209 | $this->interceptor->process( |
| 210 | 210 | $name, |
| 211 | 211 | 'bar', |
| 212 | 212 | ['headers' => ['attempts' => ['1']]], |
| 213 | 213 | $this->core |
| 214 | 214 | ); |
| 215 | - } catch (RetryException $e) { |
|
| 215 | + }catch (RetryException $e){ |
|
| 216 | 216 | $this->assertSame(5, $e->getOptions()->getDelay()); |
| 217 | 217 | $this->assertSame(['attempts' => ['2']], $e->getOptions()->getHeaders()); |
| 218 | 218 | } |
@@ -235,14 +235,14 @@ discard block |
||
| 235 | 235 | ) |
| 236 | 236 | )); |
| 237 | 237 | |
| 238 | - try { |
|
| 238 | + try{ |
|
| 239 | 239 | $this->interceptor->process( |
| 240 | 240 | $name, |
| 241 | 241 | 'bar', |
| 242 | 242 | ['headers' => ['attempts' => ['1']]], |
| 243 | 243 | $this->core |
| 244 | 244 | ); |
| 245 | - } catch (RetryException $e) { |
|
| 245 | + }catch (RetryException $e){ |
|
| 246 | 246 | $this->assertSame(8, $e->getOptions()->getDelay()); |
| 247 | 247 | $this->assertSame(['attempts' => ['2']], $e->getOptions()->getHeaders()); |
| 248 | 248 | } |
@@ -20,28 +20,28 @@ discard block |
||
| 20 | 20 | public function __construct( |
| 21 | 21 | private readonly ReaderInterface $reader, |
| 22 | 22 | private readonly HandlerRegistryInterface $registry, |
| 23 | - ) { |
|
| 23 | + ){ |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | public function process(string $controller, string $action, array $parameters, CoreInterface $core): mixed |
| 27 | 27 | { |
| 28 | - try { |
|
| 28 | + try{ |
|
| 29 | 29 | return $core->callAction($controller, $action, $parameters); |
| 30 | - } catch (\Throwable $e) { |
|
| 31 | - if (!\class_exists($controller)) { |
|
| 30 | + }catch (\Throwable $e){ |
|
| 31 | + if (!\class_exists($controller)){ |
|
| 32 | 32 | $controller = $this->registry->getHandler($controller)::class; |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | $policy = $this->getRetryPolicy($e, new \ReflectionClass($controller)); |
| 36 | 36 | |
| 37 | - if ($policy === null) { |
|
| 37 | + if ($policy === null){ |
|
| 38 | 38 | throw $e; |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | $headers = $parameters['headers'] ?? []; |
| 42 | 42 | $attempts = (int)($headers['attempts'][0] ?? 0); |
| 43 | 43 | |
| 44 | - if ($policy->isRetryable($e, $attempts) === false) { |
|
| 44 | + if ($policy->isRetryable($e, $attempts) === false){ |
|
| 45 | 45 | throw $e; |
| 46 | 46 | } |
| 47 | 47 | |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | { |
| 59 | 59 | $attribute = $this->reader->firstClassMetadata($handler, Attribute::class); |
| 60 | 60 | |
| 61 | - if ($exception instanceof JobException && $exception->getPrevious() !== null) { |
|
| 61 | + if ($exception instanceof JobException && $exception->getPrevious() !== null){ |
|
| 62 | 62 | $exception = $exception->getPrevious(); |
| 63 | 63 | } |
| 64 | 64 | |