circuitbreaker

package
v0.0.0-...-6503e2e Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2022 License: MIT Imports: 2 Imported by: 0

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

Jump to

Keyboard shortcuts

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