Versions in this module Expand all Collapse all v0 v0.0.4 Sep 14, 2020 Changes in this version + func ClearRules() error + func ClearStateChangeListeners() + func IsValid(r *Rule) error + func LoadRules(rules []*Rule) (bool, error) + func RegisterStateChangeListeners(listeners ...StateChangeListener) + func RemoveCircuitBreakerGenerator(s Strategy) error + func SetCircuitBreakerGenerator(s Strategy, generator CircuitBreakerGenFunc) error + type CircuitBreaker interface + BoundRule func() *Rule + BoundStat func() interface{} + CurrentState func() State + OnRequestComplete func(rtt uint64, err error) + TryPass func(ctx *base.EntryContext) bool + type CircuitBreakerGenFunc func(r *Rule, reuseStat interface{}) (CircuitBreaker, error) + type MetricStatSlot struct + func (c *MetricStatSlot) OnCompleted(ctx *base.EntryContext) + func (c *MetricStatSlot) OnEntryBlocked(_ *base.EntryContext, _ *base.BlockError) + func (c *MetricStatSlot) OnEntryPassed(_ *base.EntryContext) + type Rule struct + Id string + MaxAllowedRtMs uint64 + MinRequestAmount uint64 + Resource string + RetryTimeoutMs uint32 + StatIntervalMs uint32 + Strategy Strategy + Threshold float64 + func GetResRules(resource string) []*Rule + func (r *Rule) ResourceName() string + func (r *Rule) String() string + type Slot struct + func (b *Slot) Check(ctx *base.EntryContext) *base.TokenResult + type State int32 + const Closed + const HalfOpen + const Open + func (s *State) String() string + type StateChangeListener interface + OnTransformToClosed func(prev State, rule Rule) + OnTransformToHalfOpen func(prev State, rule Rule) + OnTransformToOpen func(prev State, rule Rule, snapshot interface{}) + type Strategy int8 + const ErrorCount + const ErrorRatio + const SlowRequestRatio + func (s Strategy) String() string