Documentation ¶
Index ¶
- func DefaultReadyToTrip(requestThreshold uint32, consecutiveFailures uint32, failureRate float64) func(counts gobreaker.Counts) bool
- func NewCircuitBreakerClient(options ...Options) httpclient.ClientDoer
- type CounterErrorSkipperFunc
- type OnStateChangeFunc
- type Options
- func WithCounterErrorSkipper(skipperFunc func(err error) bool) Options
- func WithHTTPClient(client *http.Client) Options
- func WithInterval(interval time.Duration) Options
- func WithMaxRequests(maxRequests uint32) Options
- func WithOnStateChangeFunc(hookFn func(name string, from gobreaker.State, to gobreaker.State)) Options
- func WithReadyToTripFunc(hookFn func(counts gobreaker.Counts) bool) Options
- func WithTimeout(timeout time.Duration) Options
- type ReadyToTripFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultReadyToTrip ¶
func DefaultReadyToTrip( requestThreshold uint32, consecutiveFailures uint32, failureRate float64, ) func(counts gobreaker.Counts) bool
DefaultReadyToTrip default function for circuit breaker
func NewCircuitBreakerClient ¶
func NewCircuitBreakerClient(options ...Options) httpclient.ClientDoer
NewCircuitBreakerClient function to instantiate http client.
Types ¶
type CounterErrorSkipperFunc ¶
CounterErrorSkipperFunc function skipper circuit breaker counter return true to skip
func (CounterErrorSkipperFunc) Apply ¶
func (c CounterErrorSkipperFunc) Apply(client *circuitBreakerClient)
Apply implements Options interface
type OnStateChangeFunc ¶
OnStateChangeFunc on state change hook
func (OnStateChangeFunc) Apply ¶
func (o OnStateChangeFunc) Apply(client *circuitBreakerClient)
Apply implements Options interface
type Options ¶
type Options interface {
Apply(*circuitBreakerClient)
}
Options interface to extend circuit breaker client
func WithCounterErrorSkipper ¶
WithCounterErrorSkipper function to bring counter error skipper to circuit breaker
func WithHTTPClient ¶
WithHTTPClient function to override http client doer
func WithInterval ¶
WithInterval function to override circuit breaker interval
func WithMaxRequests ¶
WithMaxRequests function to override circuit breaker max requests
func WithOnStateChangeFunc ¶
func WithOnStateChangeFunc(hookFn func(name string, from gobreaker.State, to gobreaker.State)) Options
WithOnStateChangeFunc function to run hook on state change
func WithReadyToTripFunc ¶
WithReadyToTripFunc function to run hook on state change
func WithTimeout ¶
WithTimeout function to override http client timeout
type ReadyToTripFunc ¶
ReadyToTripFunc on ready to trip
func (ReadyToTripFunc) Apply ¶
func (o ReadyToTripFunc) Apply(client *circuitBreakerClient)
Apply implements Options interface