Documentation ¶
Index ¶
Constants ¶
View Source
const ( OPEN uint32 = iota CLOSED HALF_CLOSED )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CircuitBreaker ¶
type CircuitBreaker struct {
// contains filtered or unexported fields
}
func New ¶
func New(settings Settings) *CircuitBreaker
func (*CircuitBreaker) Allow ¶
func (cb *CircuitBreaker) Allow() bool
Allow returns true if request allowed or false if not. Use it in your code.
func (*CircuitBreaker) Counters ¶
func (cb *CircuitBreaker) Counters() Counters
Counters return Counters object with different counters.
func (*CircuitBreaker) RegisterError ¶
func (cb *CircuitBreaker) RegisterError()
func (*CircuitBreaker) RegisterOK ¶
func (cb *CircuitBreaker) RegisterOK()
type Settings ¶
type Settings struct { Interval time.Duration // Interval after which all counters will be reset if state closed. Default disabled. Timeout time.Duration // Timeout is time after which CircuitBreaker will enter the half-closed state. Default 1 second. Threshold int // Threshold is the value after which CircuitBreaker will switch to the Open state. Default 1. MaxRequests int // MaxRequests is the number of requests that will be sent in the Half Open state. Default 1. }
Settings use it for create new CircuitBreaker object.
Click to show internal directories.
Click to hide internal directories.