Documentation
¶
Index ¶
Constants ¶
View Source
const ( // don't use 0, because 0 is reserved as indication of missing data in metrics CbState_OpenDenied = 1 CbState_ClosedAllowed = 2 // // don't use 0, because 0 is reserved as indication of missing data in metrics GState_DenyRestart = 1_00 GState_Allow = 2_00 GState_DenyWait = 3_00 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CircuitBreaker ¶
type CircuitBreaker struct {
ChanReportSize int
ChanReigniteSize int
ReignitePeriod time.Duration
CloseAllowWhenAbove int
OpenDenyWhenBelow int
DenyWaitTime time.Duration
Context context.Context
DQF_Size int
DebugMode bool
StateHookFunc StateHookFunc // dep injection // this can be used to inject code that does metrics et al
// contains filtered or unexported fields
}
func New ¶
func New(fOpts ...func(cb *CircuitBreaker)) (cb *CircuitBreaker)
func (*CircuitBreaker) IsClosedAllowed ¶
func (cb *CircuitBreaker) IsClosedAllowed() (ok bool)
func (*CircuitBreaker) Report ¶
func (cb *CircuitBreaker) Report(r bool)
func (*CircuitBreaker) WantToDo ¶
func (cb *CircuitBreaker) WantToDo(f func() (success bool)) (r bool)
type StateHookFunc ¶ added in v1.4.0
type StateHookFunc func(cbState, gState int)
Click to show internal directories.
Click to hide internal directories.