Skip to content

Commit

Permalink
Improve readme
Browse files Browse the repository at this point in the history
  • Loading branch information
stfndamjanovic committed Jan 11, 2024
1 parent 03f941a commit 4eacce6
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ composer require stfndamjanovic/php-circuit-breaker
use Stfn\CircuitBreaker\CircuitBreakerFactory;
use Stfn\CircuitBreaker\Exceptions\CircuitHalfOpenFailException;

$result = CircuitBreakerFactory::make()
->for('test-service')
$factory = CircuitBreakerFactory::make()
->for('3rd-party-api')
->failWhen(function ($result) {
if ($result->status > 400) {
throw new Exception();
Expand All @@ -33,9 +33,11 @@ $result = CircuitBreakerFactory::make()
->withOptions([
'recovery_time' => 30,
'failure_threshold' => 5
])->call(function () {
// Your function that could fail
});
]);

$result = $factory->call(function () {
// Your function that could fail
})
```

## Testing
Expand Down

0 comments on commit 4eacce6

Please sign in to comment.