publishers

package
v0.35.0 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package publishers provides implementations of various publisher strategies

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewBackoffPingingPublisher added in v0.35.0

func NewBackoffPingingPublisher(
	ctx context.Context,
	publisher worker.Publisher,
	taskFunc func() (*worker.Task, error),
	opts ...BackoffOption,
) (worker.Publisher, error)

NewBackoffPingingPublisher creates a publisher that emits ping tasks only while idle, using exponential backoff between pings.

func NewDropToStdoutPublisher

func NewDropToStdoutPublisher() worker.Publisher

NewDropToStdoutPublisher creates a new publisher instance that writes hits to stdout

func NewPingingPublisher

func NewPingingPublisher(
	ctx context.Context,
	publisher worker.Publisher,
	interval time.Duration,
	taskFunc func() (*worker.Task, error),
) worker.Publisher

NewPingingPublisher creates a new publisher that pings the given task at the given interval. Pings are only generated when no non-ping messages were published during the interval.

func NewRetryingWithFallbackPublisher

func NewRetryingWithFallbackPublisher(
	primary, fallback worker.Publisher,
	maxRetries uint,
	retryDelay time.Duration,
) worker.Publisher

NewRetryingWithFallbackPublisher creates a new storage instance with retry and fallback capabilities

Types

type BackoffOption added in v0.35.0

type BackoffOption func(*ExponentialBackoffConfig)

BackoffOption is a functional option for configuring ExponentialBackoffConfig.

func WithIntervalExpFactor added in v0.35.0

func WithIntervalExpFactor(factor float64) BackoffOption

WithIntervalExpFactor sets the exponential growth factor for the backoff.

func WithMaxInterval added in v0.35.0

func WithMaxInterval(d time.Duration) BackoffOption

WithMaxInterval sets the maximum interval for the backoff.

func WithMinInterval added in v0.35.0

func WithMinInterval(d time.Duration) BackoffOption

WithMinInterval sets the minimum interval for the backoff.

type ErrInvalidBackoffConfig added in v0.35.0

type ErrInvalidBackoffConfig struct {
	Field   string
	Message string
}

func (*ErrInvalidBackoffConfig) Error added in v0.35.0

func (e *ErrInvalidBackoffConfig) Error() string

type ExponentialBackoffConfig added in v0.35.0

type ExponentialBackoffConfig struct {
	MinInterval       time.Duration
	IntervalExpFactor float64
	MaxInterval       time.Duration
}

func (ExponentialBackoffConfig) Validate added in v0.35.0

func (c ExponentialBackoffConfig) Validate() error

type RetryingWithFallbackStorage

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

RetryingWithFallbackStorage implements Storage interface with retry logic and fallback

func (*RetryingWithFallbackStorage) Publish

Publish attempts to publish a task to the primary storage with retries. If all retries fail, it falls back to the fallback storage.

Jump to

Keyboard shortcuts

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