retry

package
v0.2.21 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Executor

type Executor struct {
	// contains filtered or unexported fields
}

Executor handles the execution of operations with retries

func NewExecutor

func NewExecutor(policy *Policy) *Executor

NewExecutor creates a new retry executor with the given policy

func (*Executor) Execute

func (e *Executor) Execute(ctx context.Context, operation func() error) error

Execute executes the given operation with retries based on the policy

type Option

type Option func(*Policy)

Option represents a retry policy option

func WithBackoffCoefficient

func WithBackoffCoefficient(coefficient float64) Option

WithBackoffCoefficient sets the backoff coefficient

func WithInitialInterval

func WithInitialInterval(interval time.Duration) Option

WithInitialInterval sets the initial interval for retries

func WithMaxAttempts

func WithMaxAttempts(attempts int32) Option

WithMaxAttempts sets the maximum number of retry attempts

func WithMaximumInterval

func WithMaximumInterval(interval time.Duration) Option

WithMaximumInterval sets the maximum interval between retries

type Policy

type Policy struct {
	InitialInterval    time.Duration
	BackoffCoefficient float64
	MaximumInterval    time.Duration
	MaximumAttempts    int32
}

Policy defines the retry policy configuration

func NewPolicy

func NewPolicy(opts ...Option) *Policy

NewPolicy creates a new retry policy with default values

Jump to

Keyboard shortcuts

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