retry

package
v0.94.1 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// StreamBaseDelay is the base delay for stream reconnect backoff.
	StreamBaseDelay = 1 * time.Second
	// StreamMaxDelay caps stream reconnect backoff delay.
	StreamMaxDelay = 30 * time.Second
	// StreamBackoffFactor is the exponential multiplier for stream reconnect backoff.
	StreamBackoffFactor = 2.0
	// StreamSyncMaxAttempts bounds synchronous subscribe/send reconnect attempts.
	StreamSyncMaxAttempts = 5
)

Variables

This section is empty.

Functions

func GRPCDialOptions

func GRPCDialOptions(l *zerolog.Logger, enabled bool) []grpc.DialOption

GRPCDialOptions returns gRPC dial options that install unary and stream retry interceptors. When enabled is false, it returns nil.

func Sleep added in v0.93.2

func Sleep(ctx context.Context, d time.Duration) error

Sleep waits for d or until ctx is cancelled.

func SleepStreamBackoff added in v0.93.2

func SleepStreamBackoff(ctx context.Context, attempt int) error

SleepStreamBackoff waits for the stream reconnect backoff delay or until ctx is cancelled.

func StreamBackoffDelay added in v0.93.2

func StreamBackoffDelay(attempt int) time.Duration

StreamBackoffDelay returns a full-jitter delay for the given stream reconnect attempt.

Types

type RestDoer

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

RestDoer retries eligible bodyless GET and HEAD requests.

func NewRestDoer

func NewRestDoer(inner httpDoer, opts ...restDoerOption) (*RestDoer, error)

NewRestDoer wraps inner with REST read retry behavior.

func (*RestDoer) Do

func (d *RestDoer) Do(req *http.Request) (*http.Response, error)

type StreamDecision added in v0.93.2

type StreamDecision int

StreamDecision describes how a stream error should be handled.

const (
	// StreamDecisionRetry indicates the stream should reconnect after a transient failure.
	StreamDecisionRetry StreamDecision = iota
	// StreamDecisionStop indicates the stream should exit without reconnecting.
	StreamDecisionStop
	// StreamDecisionNoProgress indicates reconnect would not advance the stream.
	StreamDecisionNoProgress
)

func ClassifyStreamError added in v0.93.2

func ClassifyStreamError(ctx context.Context, err error) StreamDecision

ClassifyStreamError maps a stream error to a reconnect decision: Retry for transient gRPC codes (listen loops reconnect indefinitely); Stop for permanent/cancelled errors; NoProgress for EOF, non-status, and other unknown errors (retries only until the no-progress cap).

Jump to

Keyboard shortcuts

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