Documentation
¶
Index ¶
- Variables
- func WrapBatchProcessorWithBackoffMiddleware(next goduck.BatchProcessor, config BackoffConfig) goduck.BatchProcessor
- func WrapWithBackoffMiddleware(next goduck.Processor, config BackoffConfig) goduck.Processor
- func WrapWithTimeout(next goduck.Processor, timeout time.Duration) goduck.Processor
- type BackoffConfig
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.
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
}
Click to show internal directories.
Click to hide internal directories.