circuit

package
v0.0.0-...-dc5a3c1 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2020 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrCircuitBreakerOpen error = errors.New("circuit breaker is open")

ErrCircuitBreakerOpen is the error that the breaker returns when it is open

Functions

This section is empty.

Types

type Breaker

type Breaker struct {
	// contains filtered or unexported fields
}

Breaker is a type that implements the circuit breaker pattern

func NewBreaker

func NewBreaker(tick time.Duration, threshold uint64) *Breaker

NewBreaker returns a new Breaker with the specified tick duration and failures threshold number

func (*Breaker) Do

func (b *Breaker) Do(task func() (*http.Response, error)) (*http.Response, error)

Do checks the state of the circuit breaker and executes the task accordingly

func (*Breaker) Stop

func (b *Breaker) Stop()

Stop will stop the supporting goroutine for the breaker

Jump to

Keyboard shortcuts

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