Documentation
¶
Overview ¶
Package worker delivers notifications claimed from the PostgreSQL outbox
Index ¶
Constants ¶
const AttemptTimeout = 30 * time.Second
AttemptTimeout bounds work below the database lease and shutdown grace period
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