resilience

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2024 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const BulkheadDefaultOrder = "100"
View Source
const CacheDefaultOrder = "600"
View Source
const CircuitBreakerDefaultOrder = "400"
View Source
const FallbackDefaultOrder = "700"
View Source
const RateLimiterDefaultOrder = "300"
View Source
const RetryDefaultOrder = "500"
View Source
const TimeLimiterDefaultOrder = "200"

Variables

This section is empty.

Functions

func DefaultRspCachePredicate

func DefaultRspCachePredicate(rsp Rsp, _ map[string]string) bool

func DefaultRspFailedPredicate

func DefaultRspFailedPredicate(rsp Rsp, _ map[string]string) bool

func RegisterFallbackFunction

func RegisterFallbackFunction(name string, function FallbackFunction) error

func RegisterRspCachePredicate

func RegisterRspCachePredicate(name string, predicate RspCachePredicate) error

func RegisterRspFailedPredicate

func RegisterRspFailedPredicate(name string, predicate RspFailedPredicate) error

Types

type BulkheadConfig

type BulkheadConfig struct {
	Disabled           string
	MaxConcurrentCalls string
	MaxWaitDuration    string
	WhenFullResponse   string
	Order              string
}

type CacheConfig

type CacheConfig struct {
	Enabled                       string
	Capacity                      string
	ItemTTL                       string
	ResponseCachePredicate        string
	ResponseCachePredicateContext map[string]string
	Order                         string
}

type CircuitBreakerConfig

type CircuitBreakerConfig struct {
	Disabled                              string
	SlidingWindowType                     string
	SlidingWindowSize                     string
	MinimumNumberOfCalls                  string
	FailureRateThreshold                  string
	SlowCallRateThreshold                 string
	SlowCallDurationThreshold             string
	ResponseFailedPredicate               string
	ResponseFailedPredicateContext        map[string]string
	AutomaticTransitionFromOpenToHalfOpen string
	WaitIntervalInOpenState               string
	PermittedNumberOfCallsInHalfOpenState string
	MaxWaitDurationInHalfOpenState        string
	WhenOverLoadResponse                  string
	Order                                 string
}

type Config added in v0.1.1

type Config struct {
	Bulkhead       BulkheadConfig
	TimeLimiter    TimeLimiterConfig
	RateLimiter    RateLimiterConfig
	CircuitBreaker CircuitBreakerConfig
	Retry          RetryConfig
	Cache          CacheConfig
	Fallback       FallbackConfig
}

type Decorator added in v0.1.1

type Decorator struct {
	Bulkhead       bulkhead.Bulkhead
	TimeLimiter    timelimiter.TimeLimiter
	RateLimiter    ratelimiter.RateLimiter
	CircuitBreaker circuitbreaker.CircuitBreaker
	Retry          retry.Retry
	Cache          cache.Cache[Req, Rsp]

	RegisterFn   promhelper.RegisterFn
	UnregisterFn promhelper.UnregisterFn
	// contains filtered or unexported fields
}

func NewDecorator added in v0.1.1

func NewDecorator(name string, config *Config) *Decorator

func (*Decorator) Decorate added in v0.1.1

func (e *Decorator) Decorate(rp ReverseProxy) ReverseProxy

type FallbackConfig

type FallbackConfig struct {
	Enabled                        string
	FallbackResponse               string
	FallbackFunction               string
	FallbackFunctionContext        map[string]string
	ResponseFailedPredicate        string
	ResponseFailedPredicateContext map[string]string
	Order                          string
}

type FallbackFunction

type FallbackFunction = func(Req, map[string]string) (Rsp, error)

func GetFallbackFunction

func GetFallbackFunction(name string) FallbackFunction

type OrderedDecorator added in v0.1.1

type OrderedDecorator struct {
	Decorator ReverseProxyDecorator
	// contains filtered or unexported fields
}

func NewBulkheadPlugin

func NewBulkheadPlugin(name string, config *BulkheadConfig) (bulkhead.Bulkhead, *OrderedDecorator)

func NewCachePlugin

func NewCachePlugin(name string, config *CacheConfig) (cache.Cache[Req, Rsp], *OrderedDecorator)

func NewFallbackPlugin

func NewFallbackPlugin(config *FallbackConfig) *OrderedDecorator

func NewRateLimiterPlugin

func NewRateLimiterPlugin(name string, config *RateLimiterConfig) (ratelimiter.RateLimiter, *OrderedDecorator)

func NewRetryPlugin

func NewRetryPlugin(name string, config *RetryConfig) (retry.Retry, *OrderedDecorator)

func NewTimeLimiterPlugin

func NewTimeLimiterPlugin(name string, config *TimeLimiterConfig) (timelimiter.TimeLimiter, *OrderedDecorator)

func (*OrderedDecorator) Decorate added in v0.1.1

func (d *OrderedDecorator) Decorate(rp ReverseProxy) ReverseProxy

func (*OrderedDecorator) Order added in v0.1.1

func (d *OrderedDecorator) Order() string

type RateLimiterConfig

type RateLimiterConfig struct {
	Disabled             string
	TimeoutDuration      string
	LimitRefreshPeriod   string
	LimitForPeriod       string
	WhenOverRateResponse string
	Order                string
}

type RetryConfig

type RetryConfig struct {
	Disabled                       string
	MaxAttempts                    string
	FailAfterMaxAttempts           string
	ResponseFailedPredicate        string
	ResponseFailedPredicateContext map[string]string
	WaitInterval                   string
	WhenMaxRetriesResponse         string
	Order                          string
}

type RspCachePredicate

type RspCachePredicate = func(Rsp, map[string]string) bool

func GetRspCachePredicate

func GetRspCachePredicate(name string) RspCachePredicate

type RspFailedPredicate

type RspFailedPredicate = func(Rsp, map[string]string) bool

func GetRspFailedPredicate

func GetRspFailedPredicate(name string) RspFailedPredicate

type TimeLimiterConfig

type TimeLimiterConfig struct {
	Disabled            string
	TimeoutDuration     string
	WhenTimeoutResponse string
	Order               string
}

Jump to

Keyboard shortcuts

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