circuitbreaker

package
v0.184.49 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2024 License: MPL-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CircuitExists added in v0.182.40

func CircuitExists(circuitName string) bool

func IsCircuitOpen added in v0.182.40

func IsCircuitOpen(circuitName string) bool

Expects a circuit to exist because a new circuit is always closed. Call CircuitExists to check if a circuit exists.

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.

func (*CircuitBreaker) SetOverrideCircuitNameHandler added in v0.182.40

func (c *CircuitBreaker) SetOverrideCircuitNameHandler(f func(string) string)

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