Documentation ¶
Index ¶
- Variables
- func Do(name string, req func() error) error
- func DoWithAcceptable(name string, req func() error, acceptable Acceptable) error
- func DoWithFallback(name string, req func() error, fallback func(err error) error) error
- func DoWithFallbackAcceptable(name string, req func() error, fallback func(err error) error, ...) error
- func Opt(name string, opts ...Option)
- type Acceptable
- type Breaker
- type CircuitBreaker
- func (cb *CircuitBreaker) Counts() Counts
- func (cb *CircuitBreaker) Do(req func() error) error
- func (cb *CircuitBreaker) DoWithAcceptable(req func() error, acceptable Acceptable) error
- func (cb *CircuitBreaker) DoWithFallback(req func() error, fallback func(err error) error) error
- func (cb *CircuitBreaker) DoWithFallbackAcceptable(req func() error, fallback func(err error) error, acceptable Acceptable) error
- func (cb *CircuitBreaker) Name() string
- func (cb *CircuitBreaker) State() State
- type Counts
- type Option
- type State
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrOpenState = errors.New("circuit breaker is open") ErrTooManyRequest = errors.New("too many requests") )
Functions ¶
func DoWithAcceptable ¶
func DoWithAcceptable(name string, req func() error, acceptable Acceptable) error
DoWithAcceptable calls Breaker.DoWithAcceptable on the Breaker with given name.
func DoWithFallback ¶
DoWithFallback calls Breaker.DoWithFallback on the Breaker with given name.
func DoWithFallbackAcceptable ¶
func DoWithFallbackAcceptable(name string, req func() error, fallback func(err error) error, acceptable Acceptable) error
DoWithFallbackAcceptable calls Breaker.DoWithFallbackAcceptable on the Breaker with given name.
Types ¶
type Acceptable ¶
type Breaker ¶
type Breaker interface { Name() string Counts() Counts State() State Do(req func() error) error DoWithAcceptable(req func() error, acceptable Acceptable) error DoWithFallback(req func() error, fallback func(err error) error) error DoWithFallbackAcceptable(req func() error, fallback func(err error) error, acceptable Acceptable) error }
func GetBreaker ¶
GetBreaker returns the Breaker with the given name.
type CircuitBreaker ¶
type CircuitBreaker struct {
// contains filtered or unexported fields
}
func (*CircuitBreaker) Counts ¶
func (cb *CircuitBreaker) Counts() Counts
func (*CircuitBreaker) Do ¶
func (cb *CircuitBreaker) Do(req func() error) error
func (*CircuitBreaker) DoWithAcceptable ¶
func (cb *CircuitBreaker) DoWithAcceptable(req func() error, acceptable Acceptable) error
func (*CircuitBreaker) DoWithFallback ¶
func (cb *CircuitBreaker) DoWithFallback(req func() error, fallback func(err error) error) error
func (*CircuitBreaker) DoWithFallbackAcceptable ¶
func (cb *CircuitBreaker) DoWithFallbackAcceptable(req func() error, fallback func(err error) error, acceptable Acceptable) error
func (*CircuitBreaker) Name ¶
func (cb *CircuitBreaker) Name() string
func (*CircuitBreaker) State ¶
func (cb *CircuitBreaker) State() State
type Option ¶
type Option func(opt *option)
func WithMaxRequest ¶
func WithOnSstateChange ¶
func WithReadyToTrip ¶
func WithTImeout ¶
Click to show internal directories.
Click to hide internal directories.