Skip to content

Commit

Permalink
Merge branch 'main' of github.com:stfndamjanovic/php-circuit-breaker
Browse files Browse the repository at this point in the history
  • Loading branch information
stfndamjanovic committed Jan 22, 2024
2 parents bf3033a + 47ea080 commit 7063dfd
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
5 changes: 2 additions & 3 deletions src/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ public function __construct(
int $minimumThroughput = 5,
int $recoveryTime = 60,
int $sampleDuration = 60
)
{
) {
$this->failureRatio = $failureRatio;
$this->minimumThroughput = $minimumThroughput;
$this->recoveryTime = $recoveryTime;
Expand Down Expand Up @@ -68,7 +67,7 @@ public function toArray()
'failure_ratio' => $this->failureRatio,
'minimum_throughput' => $this->minimumThroughput,
'recovery_time' => $this->recoveryTime,
'sample_duration' => $this->sampleDuration
'sample_duration' => $this->sampleDuration,
];
}
}
2 changes: 1 addition & 1 deletion src/Storage/RedisStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public function incrementSuccess(): void
protected function incrementOrCreate($key, $ttl)
{
if (! $this->redis->exists($key)) {
$this->redis->set($key, 0, $ttl);
$this->redis->set($key, 0, $ttl);
}

$this->redis->incr($key);
Expand Down
6 changes: 3 additions & 3 deletions tests/CircuitBreakerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function test_if_it_will_record_every_failure()
$breaker = CircuitBreaker::for('test-service')
->withOptions([
'failure_ratio' => 1,
'minimum_throughput' => 4
'minimum_throughput' => 4,
]);

$fail = function () {
Expand All @@ -73,7 +73,7 @@ public function test_if_it_will_not_open_breaker_when_minimum_throughput_is_not_
$breaker = CircuitBreaker::for('test-service')
->withOptions([
'failure_ratio' => 1,
'minimum_throughput' => 4
'minimum_throughput' => 4,
]);

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

0 comments on commit 7063dfd

Please sign in to comment.