cb

package
v1.2.9 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Breaker

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

Breaker wraps the endpointer and the command config required for the hysterix

func NewBreaker

func NewBreaker(fn endpoint.Endpoint, opts ...BreakerOption) (*Breaker, error)

NewBreaker returns a circuit breaker

func NewBreakerFromConfig

func NewBreakerFromConfig(
	fn endpoint.Endpoint, lg log.Logger, cfg *BreakerConf, opts ...BreakerOption,
) (*Breaker, error)

NewBreakerFromConfig builds breaker from config

func (*Breaker) Endpoint

func (b *Breaker) Endpoint() endpoint.Endpoint

Endpoint returns an endpoint which has circuit breaker wraped around it

type BreakerAfterFunc

type BreakerAfterFunc func(req interface{}, res interface{}, err error)

type BreakerConf

type BreakerConf struct {
	Enable       bool
	Timeout      int
	MaxConc      int
	VolThrs      int
	SlpWind      int
	ErrPerctThrs int
	Prefix       string
}

type BreakerOption

type BreakerOption func(*Breaker) error

BreakerOption is options that modify the Breaker

func WithBreakerAfterFunc

func WithBreakerAfterFunc(b BreakerAfterFunc) BreakerOption

func WithBreakerEnable

func WithBreakerEnable(en bool) BreakerOption

WithBreakerEnable sets if the breaker is enabled

func WithCommandPrefix

func WithCommandPrefix(prefix string) BreakerOption

WithCommandPrefix sets the prefix for the hysterix command

func WithDatadogClient

func WithDatadogClient(client *statsd.Client) BreakerOption

WithDatadogClient sets custom datadog event emitter for Tolerance

func WithErrorPercentageThreshold

func WithErrorPercentageThreshold(count int) BreakerOption

WithErrorPercentageThreshold the percentage threshold beyond which the circuit will be deemed open

func WithMaxConcurrentRequests

func WithMaxConcurrentRequests(count int) BreakerOption

WithMaxConcurrentRequests sets configuration for max concurrent requests supported for a given command

func WithMetricsCollector

func WithMetricsCollector(metrics metrics.Metrics) BreakerOption

WithMetricsCollector sets the breaker with go-base metrics event emitter

func WithRequestVolumeThreshold

func WithRequestVolumeThreshold(count int) BreakerOption

WithRequestVolumeThreshold sets the minimum number of request needed before the circuit can be tripped

func WithSleepWindow

func WithSleepWindow(inmils int) BreakerOption

WithSleepWindow sets the time in millisecond to wait after a circuit opens for testing for recovery

func WithTimeout

func WithTimeout(inmils int) BreakerOption

WithTimeout returns a circuit breaker with a given timeout

type Commander

type Commander interface {
	Command() string
}

Commander is interface implemented for breaker to extract the command from a method

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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