@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | |
| 26 | 26 | protected function checkExtensionLoaded() |
| 27 | 27 | { |
| 28 | - if (! extension_loaded('swoole')) { |
|
| 28 | + if (!extension_loaded('swoole')) { |
|
| 29 | 29 | throw new \RuntimeException('Extension swoole is required to use SwooleTableAdapter.'); |
| 30 | 30 | } |
| 31 | 31 | } |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | { |
| 56 | 56 | $key = "{$service}-failures"; |
| 57 | 57 | |
| 58 | - if (! $this->table->exist($key)) { |
|
| 58 | + if (!$this->table->exist($key)) { |
|
| 59 | 59 | return false; |
| 60 | 60 | } |
| 61 | 61 | |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | { |
| 88 | 88 | $key = "{$service}-open"; |
| 89 | 89 | |
| 90 | - if (! $this->table->exists($key)) { |
|
| 90 | + if (!$this->table->exists($key)) { |
|
| 91 | 91 | return false; |
| 92 | 92 | } |
| 93 | 93 | |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | { |
| 105 | 105 | $key = "{$service}-half_open"; |
| 106 | 106 | |
| 107 | - if (! $this->table->exists($key)) { |
|
| 107 | + if (!$this->table->exists($key)) { |
|
| 108 | 108 | return false; |
| 109 | 109 | } |
| 110 | 110 | |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | |
| 30 | 30 | protected function checkExtensionLoaded() |
| 31 | 31 | { |
| 32 | - if (! extension_loaded('redis')) { |
|
| 32 | + if (!extension_loaded('redis')) { |
|
| 33 | 33 | throw new \RuntimeException('Extension redis is required to use RedisAdapter.'); |
| 34 | 34 | } |
| 35 | 35 | } |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | { |
| 80 | 80 | $serviceName = $this->makeNamespace($service) . ':failures'; |
| 81 | 81 | |
| 82 | - if (! $this->redis->get($serviceName)) { |
|
| 82 | + if (!$this->redis->get($serviceName)) { |
|
| 83 | 83 | $this->redis->multi(); |
| 84 | 84 | $this->redis->incr($serviceName); |
| 85 | 85 | $this->redis->expire($serviceName, $timeWindow); |
@@ -16,9 +16,9 @@ discard block |
||
| 16 | 16 | |
| 17 | 17 | public function __invoke(callable $handler): \Closure |
| 18 | 18 | { |
| 19 | - return function (RequestInterface $request, array $options) use ($handler) { |
|
| 19 | + return function(RequestInterface $request, array $options) use ($handler) { |
|
| 20 | 20 | |
| 21 | - if (! $this->circuitBreaker->isAvailable()) { |
|
| 21 | + if (!$this->circuitBreaker->isAvailable()) { |
|
| 22 | 22 | throw new CircuitBreakerException( |
| 23 | 23 | sprintf('"%s" is not available', $this->circuitBreaker->getService()) |
| 24 | 24 | ); |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | $promise = $handler($request, $options); |
| 28 | 28 | |
| 29 | 29 | return $promise->then( |
| 30 | - function (ResponseInterface $response) { |
|
| 30 | + function(ResponseInterface $response) { |
|
| 31 | 31 | $this->executeCircuitBreakerOnResponse($response); |
| 32 | 32 | |
| 33 | 33 | return $response; |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | { |
| 41 | 41 | $statusCode = $response->getStatusCode(); |
| 42 | 42 | |
| 43 | - if (! $this->isStatusCodeRangeValid($statusCode)) { |
|
| 43 | + if (!$this->isStatusCodeRangeValid($statusCode)) { |
|
| 44 | 44 | $this->circuitBreaker->failure(); |
| 45 | 45 | return; |
| 46 | 46 | } |
@@ -18,11 +18,11 @@ |
||
| 18 | 18 | $circuit->setSettings([ |
| 19 | 19 | 'timeWindow' => 60, // Time for an open circuit (seconds) |
| 20 | 20 | 'failureRateThreshold' => 50, // Fail rate for open the circuit |
| 21 | - 'intervalToHalfOpen' => 30, // Half open time (seconds) |
|
| 21 | + 'intervalToHalfOpen' => 30, // Half open time (seconds) |
|
| 22 | 22 | ]); |
| 23 | 23 | |
| 24 | 24 | // Check circuit status for service |
| 25 | -if (! $circuit->isAvailable()) { |
|
| 25 | +if (!$circuit->isAvailable()) { |
|
| 26 | 26 | die('Circuit is not available!'); |
| 27 | 27 | } |
| 28 | 28 | |