Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CircuitBreaker ¶
func New ¶
func New(name string, config Config) *CircuitBreaker
type Config ¶
type Config struct {
// Timeout for the execution context.
Timeout time.Duration
// MaxConcurrent the maximum number of requests allowed to be executed at one time.
MaxConcurrent int64
// NumBuckets the number of buckets the rolling window is divided into.
NumBuckets int
// BucketWidth used to compute the duration of the statistical rolling window.
BucketWidth time.Duration
// RequestVolumeThreshold number of requests in the rolling window that will trigger
// a check on the total number of requests as a percentage (ErrorThresholdPercentage).
// For example, if the value is 20, then if only 19 requests are received in the rolling window
// the circuit will not trigger percentage check to open the circuit.
// Set 1 to disable and always trigger percentage check.
RequestVolumeThreshold int64
// TotalThresholdPercent ratio in the rolling window of the number of failed requests to the total number of requests.
// For example, if the value is 10, if total requests in the rolling window is 100 when failed requests is 10,
// then 10/100 >= 10% -> the circuit will be open.
ErrorThresholdPercentage int64
// SleepWindow how long to deny requests before allowing attempts
// again to determine if the chain should be closed again.
SleepWindow time.Duration
}
Click to show internal directories.
Click to hide internal directories.


