Skip to content

Commit

Permalink
Polishing
Browse files Browse the repository at this point in the history
  • Loading branch information
stfndamjanovic committed Jan 24, 2024
1 parent 5e5778b commit 5cdc6f4
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
1 change: 0 additions & 1 deletion src/Storage/CircuitBreakerStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Stfn\CircuitBreaker\CircuitBreaker;
use Stfn\CircuitBreaker\CircuitState;
use Stfn\CircuitBreaker\Counter;

abstract class CircuitBreakerStorage
{
Expand Down
7 changes: 2 additions & 5 deletions src/Storage/RedisStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Stfn\CircuitBreaker\CircuitBreaker;
use Stfn\CircuitBreaker\CircuitState;
use Stfn\CircuitBreaker\Counter;

class RedisStorage extends CircuitBreakerStorage
{
Expand All @@ -19,9 +18,8 @@ class RedisStorage extends CircuitBreakerStorage
protected \Redis $redis;

/**
* @param string $service
* @param \Redis $redis
* @throws \RedisException
* @throws \Exception
*/
public function __construct(\Redis $redis)
{
Expand All @@ -33,7 +31,7 @@ public function __construct(\Redis $redis)
}

/**
* @param string $service
* @param CircuitBreaker $breaker
* @return void
* @throws \RedisException
*/
Expand Down Expand Up @@ -99,7 +97,6 @@ protected function incrementOrCreate($key, $ttl)
public function resetCounter(): void
{
$this->redis->del($this->getNamespace(self::FAIL_COUNT_KEY));
$this->redis->del($this->getNamespace(self::SUCCESS_COUNT_KEY));
}

/**
Expand Down
6 changes: 3 additions & 3 deletions tests/CircuitBreakerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function test_if_it_will_record_every_failure()
{
$breaker = CircuitBreaker::for('test-service')
->withOptions([
'failure_threshold' => 4
'failure_threshold' => 4,
]);

$fail = function () {
Expand All @@ -71,7 +71,7 @@ public function test_if_it_will_open_circuit_when_failure_threshold_is_reached()
{
$breaker = CircuitBreaker::for('test-service')
->withOptions([
'failure_threshold' => 3
'failure_threshold' => 3,
]);

$fail = function () {
Expand Down Expand Up @@ -201,7 +201,7 @@ public function test_if_it_can_fail_even_without_exception()
{
$breaker = CircuitBreaker::for('test-service')
->withOptions([
'failure_threshold' => 3
'failure_threshold' => 3,
])
->failWhen(function ($result) {
return $result instanceof \stdClass;
Expand Down

0 comments on commit 5cdc6f4

Please sign in to comment.