middleware

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecorrelatedJitter

func DecorrelatedJitter(baseDelay, maxDelay, prevDelay time.Duration) time.Duration

func EqualJitter

func EqualJitter(baseDelay, maxDelay time.Duration, attempt int) time.Duration

func FullJitter

func FullJitter(baseDelay, maxDelay time.Duration, attempt int) time.Duration

func IsPermanent

func IsPermanent(err error) bool

func IsRetryable

func IsRetryable(err error) bool

func LoggingMiddleware

func LoggingMiddleware(logger zerolog.Logger) worker.Middleware

func MetricsMiddleware

func MetricsMiddleware(collector MetricsCollector) worker.Middleware

func Permanent

func Permanent(err error) error

func RecoveryMiddleware

func RecoveryMiddleware(logger zerolog.Logger) worker.Middleware

func Retry

func Retry(err error) error

func TimeoutMiddleware

func TimeoutMiddleware(defaultTimeout time.Duration) worker.Middleware

Types

type BackoffConfig

type BackoffConfig struct {
	Strategy     BackoffStrategy
	BaseDelay    time.Duration
	MaxDelay     time.Duration
	JitterFactor float64
	Multiplier   float64
}

func DefaultBackoffConfig

func DefaultBackoffConfig() BackoffConfig

func (BackoffConfig) CalculateDelay

func (c BackoffConfig) CalculateDelay(attempt int) time.Duration

type BackoffStrategy

type BackoffStrategy int
const (
	BackoffConstant BackoffStrategy = iota
	BackoffLinear
	BackoffExponential
)

type MetricsCollector

type MetricsCollector interface {
	JobStarted(jobType, queue string)
	JobCompleted(jobType, queue string, duration time.Duration)
	JobFailed(jobType, queue string, duration time.Duration)
	JobRetrying(jobType, queue string, attempt int)
}

type PanicError

type PanicError struct {
	Value interface{}
}

func (*PanicError) Error

func (e *PanicError) Error() string

type PermanentError

type PermanentError struct {
	Err error
}

func (*PermanentError) Error

func (e *PermanentError) Error() string

func (*PermanentError) Unwrap

func (e *PermanentError) Unwrap() error

type RetryableError

type RetryableError struct {
	Err error
}

func (*RetryableError) Error

func (e *RetryableError) Error() string

func (*RetryableError) Unwrap

func (e *RetryableError) Unwrap() error

Jump to

Keyboard shortcuts

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