Passed
Push — master ( 093622...13cd72 )
by butschster
06:20 queued 19s
created
src/Queue/tests/Interceptor/Consume/RetryPolicyInterceptorTest.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -79,9 +79,9 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
         }
Please login to merge, or discard this patch.
src/Queue/src/Interceptor/Consume/RetryPolicyInterceptor.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -18,24 +18,24 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.