breaker

package
v0.28.0 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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

Functions

This section is empty.

Types

type Breaker

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

Breaker implements circuit breaker pattern

func New

func New(threshold int, timeout time.Duration) *Breaker

New creates a circuit breaker

func (*Breaker) Call

func (b *Breaker) Call(fn func() error) error

Call executes fn with circuit breaker protection

func (*Breaker) Reset

func (b *Breaker) Reset()

Reset resets the breaker

func (*Breaker) State

func (b *Breaker) State() State

State returns current state

type State

type State int
const (
	StateClosed State = iota
	StateOpen
	StateHalfOpen
)

Jump to

Keyboard shortcuts

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