Skip to content

Commit

Permalink
Update readme (#35)
Browse files Browse the repository at this point in the history
* Modify the comment for IsSuccessful

* Update README
  • Loading branch information
YoshiyukiMineo authored Oct 21, 2021
1 parent c8b8ad0 commit 602fbde
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ type Settings struct {
Timeout time.Duration
ReadyToTrip func(counts Counts) bool
OnStateChange func(name string, from State, to State)
IsSuccessful func(err error) bool
}
```

Expand All @@ -56,6 +57,11 @@ type Settings struct {

- `OnStateChange` is called whenever the state of `CircuitBreaker` changes.

- `IsSuccessful` is called with the error returned from a request.
If `IsSuccessful` returns true, the error is counted as a success.
Otherwise the error is counted as a failure.
If `IsSuccessful` is nil, default `IsSuccessful` is used, which returns false for all non-nil errors.

The struct `Counts` holds the numbers of requests and their successes/failures:

```go
Expand Down
6 changes: 3 additions & 3 deletions gobreaker.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ func (c *Counts) clear() {
//
// OnStateChange is called whenever the state of the CircuitBreaker changes.
//
// IsSuccessful is called with the error returned from the request, if not nil.
// If IsSuccessful returns false, the error is considered a failure, and is counted towards tripping the circuit breaker.
// If IsSuccessful returns true, the error will be returned to the caller without tripping the circuit breaker.
// IsSuccessful is called with the error returned from a request.
// If IsSuccessful returns true, the error is counted as a success.
// Otherwise the error is counted as a failure.
// If IsSuccessful is nil, default IsSuccessful is used, which returns false for all non-nil errors.
type Settings struct {
Name string
Expand Down

0 comments on commit 602fbde

Please sign in to comment.