processormiddleware

package
v0.15.5 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2025 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultBackoffConfig = BackoffConfig{
	InitialDelay: 200 * time.Millisecond,
	MaxDelay:     10 * time.Second,
	Spread:       0.2,
	Factor:       1.5,
}

Functions

func WrapBatchProcessorWithBackoffMiddleware

func WrapBatchProcessorWithBackoffMiddleware(next goduck.BatchProcessor, config BackoffConfig) goduck.BatchProcessor

WrapBatchProcessorWithBackoffMiddleware tries to execute @next.BatchProcess() until it succeeds. Each failure is followed by an exponentially increasing delay.

func WrapWithBackoffMiddleware

func WrapWithBackoffMiddleware(next goduck.Processor, config BackoffConfig) goduck.Processor

WrapWithBackoffMiddleware tries to execute @next.Process() until it succeeds. Each failure is followed by an exponentially increasing delay.

func WrapWithTimeout

func WrapWithTimeout(next goduck.Processor, timeout time.Duration) goduck.Processor

Types

type BackoffConfig

type BackoffConfig struct {
	// InitialDelay represents the delay after the first error, before adding
	// the spread
	InitialDelay time.Duration

	// MaxDelay represents the max delay after an error, before adding the
	// spread
	MaxDelay time.Duration

	// Spread is the percentage of the current delay that can be added as a
	// random term. For example, with a delay of 10s and 20% spread, the
	// calculated delay will be between 10s and 12s.
	Spread float64

	// Factor represents how bigger the next delay wil be in comparison to the
	// current one
	Factor float64
}

Jump to

Keyboard shortcuts

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