Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BasicDetector ¶
type BasicDetector struct {
// contains filtered or unexported fields
}
BasicDetector is a state machine to prevent sending requests that are likely to fail.
func NewBasicDetector ¶
func NewBasicDetector(name string, opts Options) *BasicDetector
NewBasicDetector returns a new BasicDetector configured with the given Options.
func (*BasicDetector) Counter ¶
func (d *BasicDetector) Counter() Counter
Counter returns internal counters
func (*BasicDetector) Name ¶
func (d *BasicDetector) Name() string
Name returns the name of the BasicDetector.
func (*BasicDetector) Reset ¶
func (d *BasicDetector) Reset()
func (*BasicDetector) State ¶
func (d *BasicDetector) State() State
State returns the current state of the BasicDetector.
type Options ¶
type Options struct { // Timeout is the period of the open state, // after which the state of the BasicDetector becomes half-open. // If Timeout is less than or equal to 0, the timeout value of the BasicDetector is set to 60 seconds. Timeout time.Duration // NormalConditionFn is called with a copy of Counter whenever a request success in the anomaly state. // If NormalConditionFn returns true, the BasicDetector will be placed into the ok state. // If NormalConditionFn is nil, default NormalConditionFn is used. // Default NormalConditionFn returns true when the number of consecutive normalities is more than 3. NormalConditionFn func(counter Counter) bool // AnomalyConditionFn is called with a copy of Counter whenever a request fails in the ok state. // If AnomalyConditionFn returns true, the BasicDetector will be placed into the anomaly state. // If AnomalyConditionFn is nil, default AnomalyConditionFn is used. // Default AnomalyConditionFn returns true when the number of consecutive abnormalities is more than 5. AnomalyConditionFn func(counter Counter) bool // OnStateChange is called whenever the state of the BasicDetector changes. OnStateChange func(name string, from State, to State) }
Options configures BasicDetector
Click to show internal directories.
Click to hide internal directories.