breaker

package
v1.8.0-rc.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 23, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrOpenState       = gobreaker.ErrOpenState
	ErrTooManyRequests = gobreaker.ErrTooManyRequests
)

Functions

func IsErrorPermanent

func IsErrorPermanent(err error) bool

IsErrorPermanent returns true if `err` should be treated as a permanent error that cannot be retried.

Types

type CircuitBreaker

type CircuitBreaker struct {
	// Name is the circuit breaker name.
	Name string
	// The maximum number of requests allowed to pass through when
	// the circuit breaker is half-open.
	// Default is 1.
	MaxRequests uint32 `mapstructure:"maxRequests"`
	// The cyclic period of the closed state for the circuit breaker
	// to clear the internal counts. If 0, the circuit breaker doesn't
	// clear internal counts during the closed state.
	// Default is 0s.
	Interval time.Duration `mapstructure:"interval"`
	// The period of the open state, after which the state of the
	// circuit breaker becomes half-open.
	// Default is 60s.
	Timeout time.Duration `mapstructure:"timeout"`
	// Trip is a CEL expression evaluated with the circuit breaker's
	// internal counts whenever a request fails in the closed state.
	// If it evaluates to true, the circuit breaker will be placed
	// into the open state.
	// Default is consecutiveFailures > 5.
	Trip *expr.Expr `mapstructure:"trip"`
	// contains filtered or unexported fields
}

CircuitBreaker represents the configuration for how a circuit breaker behaves.

func (*CircuitBreaker) Execute

func (c *CircuitBreaker) Execute(oper func() error) error

Execute invokes `oper` if the circuit breaker is in an closed state or for an allowed call in the half-open state.

func (*CircuitBreaker) Initialize

func (c *CircuitBreaker) Initialize(log logger.Logger)

Initialize creates the underlying circuit breaker using the configuration fields.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL