circuitbreaker

package
v0.0.0-...-8ffcee5 Latest Latest
Warning

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

Go to latest
Published: May 24, 2024 License: MIT Imports: 6 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Do

func Do[T any](cb CircuitBreaker, cmd string, onHandle Handler, onError ErrorHandler) (*T, error)

Do is a helper function that wraps the CircuitBreaker.Do method and returns the result as the expected type.

Types

type CircuitBreaker

type CircuitBreaker interface {
	Do(cmd string, onHandle Handler, onError ErrorHandler) (any, error)
}

func New

func New(conf *config.Config, logger logging.Logger) (CircuitBreaker, error)

New creates a new CircuitBreaker instance that is using go-breaker of Sony by default.

func NewGoBreaker

func NewGoBreaker(conf *config.Config, logger logging.Logger) (CircuitBreaker, error)

NewGoBreaker creates a new circuit breaker instance that is using go-breaker as the implementation and the LRU cache for the storage. For each command, it will create a new circuit breaker instance and store it in the LRU cache. That means, if the command is not used for a while, it will be removed from the cache to free up the memory.

type ErrorHandler

type ErrorHandler func(err error) error

type Handler

type Handler func() (any, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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