Help us shape the future of Go! Take the 2026 Go Developer Survey

circut

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2025 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Breaker

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

Breaker helps manage back-off in case of a resource checked by prober is unavailable.

func New

func New(resetDuration time.Duration, prober Prober) *Breaker

New creates a new circut breaker

func (*Breaker) FlagDown

func (b *Breaker) FlagDown()

FlagDown is used to indicate the resource is down.

func (*Breaker) FlagUp

func (b *Breaker) FlagUp()

FlagUp is used to reset the backoff.

func (*Breaker) IsUp

func (b *Breaker) IsUp() bool

IsUp returns true if resource is up, and will trigger a probe if it is due.

type Prober

type Prober interface {
	// Probe checks if service is up, if so it should call FlagUp
	Probe()
}

Prober represents abstraction to check if service is up. Types implementing this interface should also have access to the Breaker that will call Prober.Probe().

Jump to

Keyboard shortcuts

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