breaker

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2021 License: Apache-2.0 Imports: 8 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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