Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var FailureOnExternalErrorPolicy = func(_ context.Context, err error) limit.Result { if err == nil { return limit.ResultSuccess } if err != nil && err != errors.ErrRejectedExecution { return limit.ResultFailure } return limit.ResultIgnore }
FailureOnExternalErrorPolicy will treat as failure every error that is not from concurrencylimit package (this is the error by the limiters).
var FailureOnRejectedPolicy = func(_ context.Context, err error) limit.Result { if err == nil { return limit.ResultSuccess } if err != nil && err == errors.ErrRejectedExecution { return limit.ResultFailure } return limit.ResultIgnore }
FailureOnRejectedPolicy will treat as failure every time the execution has been rejected with a `errors.ErrRejectedExecution` error.
var NoFailurePolicy = func(_ context.Context, err error) limit.Result { if err == nil { return limit.ResultSuccess } return limit.ResultIgnore }
NoFailurePolicy will treat will never return a failure, just ignore when an error occurs, this can be used to adapt only on RTT/latency.
Functions ¶
func New ¶
func New(cfg Config) goresilience.Runner
New returns a new goresilience concurrency limit Runner.
func NewMiddleware ¶
func NewMiddleware(cfg Config) goresilience.Middleware
NewMiddleware returns a new concurrent limit middleware
Types ¶
type Config ¶
type Config struct { // Limiter is the algorithm implementation that will calculate // the limits in adaptive way. Limiter limit.Limiter // Executor is the implementation used to execute the functions internally. It maintains // the workers dynamically based on the CongestionControlAlgorithm limits. Executor execute.Executor // ExecutionResultPolicy is a function where the execution error will be passed along with // the context and return if that result should be treated as a success, an error or ignored // by the concurrency control algorithm. // By default every error will count as an error. ExecutionResultPolicy ExecutionResultPolicy }
Config is the concurrency limit algorithm
type ExecutionResultPolicy ¶
ExecutionResultPolicy is the function that will have the responsibility of categorizing the result of the execution for the limiter algorithm. For example depending on the type of the execution a connection error could be treated like an failure in the algorithm or just ignore it.