breaker

package
v1.3.6 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// StateClosed when circuit breaker closed, request allowed, the breaker
	// calc the succeed ratio, if request num greater request setting and
	// ratio lower than the setting ratio, then reset state to open.
	StateClosed int32 = iota
	// StateOpen when circuit breaker open, request not allowed, after sleep
	// some duration, allow one single request for testing the health, if ok
	// then state reset to closed, if not continue the step.
	StateOpen
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Breaker

type Breaker interface {
	Allow() error
	Accept()
	Reject()
}

type BreakerGroup

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

BreakerGroup brks

func NewBreakerGroup

func NewBreakerGroup() *BreakerGroup

NewBreakerGroup returns global breaker group instance brks

func (*BreakerGroup) Do

func (bg *BreakerGroup) Do(name string, run func() error, accept func(error) bool) error

Do execute the input func and stats the breaker result

func (*BreakerGroup) Get

func (bg *BreakerGroup) Get(name string) Breaker

Get return a break associate with the name

type GoogleSreBreakerConfig

type GoogleSreBreakerConfig struct {
	K          float64
	Window     time.Duration
	BucketSize int
	Name       string
}

type Proba

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

func NewProba

func NewProba() *Proba

NewProba return Proba pointer

func (*Proba) TrueOnProba

func (p *Proba) TrueOnProba(proba float64) bool

TrueOnProba check if input proba less than pseudo-random number

Jump to

Keyboard shortcuts

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