Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrBreakerOpen = breaker.ErrBreakerOpen
ErrBreakerOpen used for breaker open error
Functions ¶
This section is empty.
Types ¶
type CircuitBreaker ¶
type CircuitBreaker struct {
// contains filtered or unexported fields
}
CircuitBreaker struct for circuitbreaker
func New ¶
func New(errorThreshold int, successThreshold int, timeout int) CircuitBreaker
New used to create circuit breaker errorThreshold is how many times error before CB open successThreshold is how many times success needed before CB become closed from half-open timeout is how long CB will open before change to half-open (in millisecond)
func (CircuitBreaker) Run ¶
func (cb CircuitBreaker) Run(f func() error) error
Run used for running function with circuit breaker This will return error either circuit breaker open or the error from your function You can check if circuit breaker open from ErrBreakerOpen
Click to show internal directories.
Click to hide internal directories.