Help us shape the future of Go! Take the 2026 Go Developer Survey

worker

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package worker drains the pending-delivery queue: it claims due deliveries, performs them through the delivery engine, records each attempt, and either reschedules with backoff or dead-letters on exhaustion.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	Concurrency  int
	PollInterval time.Duration
	Lease        time.Duration
	Backoff      core.BackoffConfig
	Metrics      Recorder
	// DrainTimeout bounds how long Run waits for in-flight deliveries to finish
	// after the context is cancelled before force-cancelling them.
	DrainTimeout time.Duration
}

Options configures the worker pool.

type Recorder

type Recorder interface {
	RecordDelivery(outcome string)
	RecordDeadLetter()
}

Recorder receives delivery telemetry. *metrics.Metrics satisfies it.

type Worker

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

Worker drains the queue using an injected delivery engine.

func New

func New(store storage.Store, engine *delivery.Engine, logger *slog.Logger, opts Options) *Worker

New builds a worker. Concurrency, PollInterval, and Lease fall back to sane defaults when zero.

func (*Worker) Run

func (w *Worker) Run(ctx context.Context) error

Run polls the queue until ctx is cancelled, then stops claiming new work and lets in-flight deliveries finish (up to DrainTimeout) before returning. Deliveries run on a context independent of ctx so they survive shutdown.

Jump to

Keyboard shortcuts

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