worker

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: MIT Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package worker delivers notifications claimed from the PostgreSQL outbox

Index

Constants

View Source
const AttemptTimeout = 30 * time.Second

AttemptTimeout bounds work below the database lease and shutdown grace period

View Source
const MisconfigurationPause = time.Minute

MisconfigurationPause is the minimal worker-wide pause after the provider refuses sender credentials or configuration

Variables

This section is empty.

Functions

This section is empty.

Types

type Sender

type Sender interface {
	Send(ctx context.Context, email notification.Email, idempotencyKey string) (string, error)
}

Sender submits an immutable email using a stable idempotency key

type Store

type Store interface {
	ClaimNotification(ctx context.Context, owner string) (database.Notification, error)
	NotificationEligible(ctx context.Context, n database.Notification, email string) (bool, error)
	CompleteNotification(ctx context.Context, n database.Notification, messageID string) error
	RetryNotification(ctx context.Context, n database.Notification, delay time.Duration, reason string) error
	FinishNotification(ctx context.Context, n database.Notification, status, reason string) error
	ExpireNotifications(ctx context.Context) error
	PurgeNotifications(ctx context.Context) error
	NotificationStats(ctx context.Context) (database.NotificationStats, error)
}

Store persists claims and ownership-fenced delivery transitions

type Worker

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

Worker drains due notifications with bounded attempts and crash-recoverable leases

func New

func New(log *zap.Logger, store Store, sender Sender, registry prometheus.Registerer) *Worker

New creates one independently identified worker and registers its metrics

func (*Worker) Run

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

Run stops acquiring work on cancellation, while an already claimed attempt may finish

Jump to

Keyboard shortcuts

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