circuitbreaker

package
v0.74.0 Latest Latest
Warning

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

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

Documentation

Overview

Package circuitbreaker provides a circuit breaker pattern implementation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action func() (interface{}, error)

Action function to execute in circuit breaker.

type CircuitBreaker

type CircuitBreaker struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

CircuitBreaker implementation.

func New

func New(name string, s Setting) (*CircuitBreaker, error)

New returns a new instance.

func (*CircuitBreaker) Execute

func (cb *CircuitBreaker) Execute(act Action) (interface{}, error)

Execute the provided action.

type OpenError

type OpenError struct{}

OpenError definition for the open state.

func (OpenError) Error

func (oe OpenError) Error() string

type Setting

type Setting struct {
	// FailureThreshold for the circuit to open.
	FailureThreshold uint
	// RetryTimeout after which we set the state to half-open and allow a retry.
	RetryTimeout time.Duration
	// RetrySuccessThreshold which returns the state to open.
	RetrySuccessThreshold uint
	// MaxRetryExecutionThreshold which defines how many tries are allowed when the status is half-open.
	MaxRetryExecutionThreshold uint
}

Setting definition.

Jump to

Keyboard shortcuts

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