Documentation
¶
Index ¶
- Variables
- func DefaultIsIgnorable(err error) bool
- func DefaultIsSuccessful(err error) bool
- func GuardBy[T any](cb *CircuitBreaker, f func() (T, error)) (r T, err error)
- func Ignore(err error) error
- func Success(err error) error
- func WithClock(clock clock.Clock) option
- func WithFailureRate(p float32) option
- func WithHook(h Hook) option
- func WithIsIgnorable(f func(error) bool) option
- func WithIsSuccessful(f func(error) bool) option
- func WithNumberOfCallsInHalfState(n int32) option
- func WithResetTimeout(d time.Duration) option
- type CircuitBreaker
- type CircuitBreakerState
- type Hook
- type IgnorableError
- type SuccessfulError
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrOpen = errors.New("circuit breaker is open")
)
Functions ¶
func DefaultIsIgnorable ¶
func DefaultIsSuccessful ¶
func WithFailureRate ¶
func WithFailureRate(p float32) option
func WithIsIgnorable ¶
func WithIsSuccessful ¶
func WithNumberOfCallsInHalfState ¶
func WithNumberOfCallsInHalfState(n int32) option
func WithResetTimeout ¶
Types ¶
type CircuitBreaker ¶
type CircuitBreaker struct {
// contains filtered or unexported fields
}
func New ¶
func New(opts ...option) *CircuitBreaker
type CircuitBreakerState ¶
type CircuitBreakerState string
const ( StateOpen CircuitBreakerState = "open" StateClosed CircuitBreakerState = "closed" StateHalfOpen CircuitBreakerState = "half-open" )
type Hook ¶
type Hook func(old, new CircuitBreakerState)
type IgnorableError ¶
type IgnorableError struct {
// contains filtered or unexported fields
}
func (*IgnorableError) Error ¶
func (e *IgnorableError) Error() string
func (*IgnorableError) Unwrap ¶
func (e *IgnorableError) Unwrap() error
type SuccessfulError ¶
type SuccessfulError struct {
// contains filtered or unexported fields
}
func (*SuccessfulError) Error ¶
func (e *SuccessfulError) Error() string
func (*SuccessfulError) Unwrap ¶
func (e *SuccessfulError) Unwrap() error
Click to show internal directories.
Click to hide internal directories.