circuitbreaker

package
v0.181.35 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2024 License: MPL-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 CircuitBreaker

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

func NewCircuitBreaker

func NewCircuitBreaker(config Config) *CircuitBreaker

func (*CircuitBreaker) Execute

func (cb *CircuitBreaker) Execute(cmd *Command) CommandResult

Executes the command in its circuit if set. If the command's circuit is not configured, the circuit of the CircuitBreaker is used. This is a blocking function.

type Command

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

func NewCommand

func NewCommand(ctx context.Context, functors []*Functor) *Command

func (*Command) Add

func (cmd *Command) Add(ftor *Functor)

func (*Command) Cancel added in v0.181.34

func (cmd *Command) Cancel()

func (*Command) IsEmpty

func (cmd *Command) IsEmpty() bool

type CommandResult

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

func (CommandResult) Error

func (cr CommandResult) Error() error

func (CommandResult) Result

func (cr CommandResult) Result() []any

type Config

type Config struct {
	Timeout                int
	MaxConcurrentRequests  int
	RequestVolumeThreshold int
	SleepWindow            int
	ErrorPercentThreshold  int
}

type FallbackFunc

type FallbackFunc func() ([]any, error)

type Functor

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

func NewFunctor

func NewFunctor(exec FallbackFunc, circuitName string) *Functor

Jump to

Keyboard shortcuts

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