retry

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RetryConditionFromRegex

func RetryConditionFromRegex(regexes ...regexp.Regexp) func(ruleResult rule.RuleResult) bool

RetryConditionFromRegex generates a retry condition func that matches messages from rule.Errored statuses.

Types

type CreateOption

type CreateOption func(*RetryableRule)

CreateOption is a function that acts on a RetryableRule and is used to construct such objects.

func WithBaseRule

func WithBaseRule(baseRule rule.Rule) CreateOption

WithBaseRule sets the BaseRule of a RetryableRule.

func WithLogger

func WithLogger(logger Logger) CreateOption

WithLogger the logger of a RetryableRule.

func WithMaxRetries

func WithMaxRetries(maxRetries int) CreateOption

WithMaxRetries sets the MaxRetries of a RetryableRule.

func WithRetryCondition

func WithRetryCondition(retryCondition func(ruleResult rule.RuleResult) bool) CreateOption

WithRetryCondition sets the RetryCondition of a RetryableRule.

type Logger

type Logger interface {
	Info(string, ...any)
}

Logger is a minimalistic logger interface.

type RetryableRule

type RetryableRule struct {
	BaseRule       rule.Rule
	MaxRetries     int
	RetryCondition func(ruleResult rule.RuleResult) bool
	Logger         Logger
}

RetryableRule wraps rule.Rule and allows a rule to be retried when the retry condition is met.

func New

func New(options ...CreateOption) *RetryableRule

New creates a new RetryableRule.

func (*RetryableRule) ID

func (rr *RetryableRule) ID() string

ID returns the id of the rule.

func (*RetryableRule) Name

func (rr *RetryableRule) Name() string

Name returns the name of the rule.

func (*RetryableRule) Run

Run executes the base rule and retries when the retry condition is met and max retries are not reached yet.

Jump to

Keyboard shortcuts

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