Documentation
¶
Overview ¶
Package notifyworker drains the notification queue: it claims due rows under a lease, renders them, delivers them over SMTP, and resolves each batch to sent, retried, or failed.
It owns the delivery policy — the deliverability gate, the retry budget and its backoff, and the retention purge that bounds the table — and holds the rendering and transport layers behind the two collaborators in Config.
Index ¶
Constants ¶
const ( // DefaultPollEvery is the fallback poll interval when LISTEN/NOTIFY does // not wake the worker. DefaultPollEvery = 30 * time.Second // DefaultLease bounds one delivery attempt; an expired lease returns the // row to claimable state for crash recovery. DefaultLease = 2 * time.Minute // DefaultMaxAttempts is the delivery attempt budget per row. DefaultMaxAttempts = 5 // DefaultResolvedRetention keeps sent/failed rows for operator // inspection before the purge removes them. DefaultResolvedRetention = 30 * 24 * time.Hour // DefaultPendingTTL bounds how long an undelivered row stays relevant. // Beyond it the event is stale (nobody wants a share email from last // month when SMTP is finally configured) and the purge drops it. DefaultPendingTTL = 7 * 24 * time.Hour )
Worker defaults.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Queue notification.QueueStore
Settings smtp.SettingsStore
Renderer *notifyrender.Renderer
Sender notifysend.Sender
// PollEvery, Lease, and MaxAttempts default to the package constants
// when zero.
PollEvery time.Duration
Lease time.Duration
MaxAttempts int
}
Config configures the send worker.
type Worker ¶
type Worker struct {
// contains filtered or unexported fields
}
Worker drains the notification queue: it claims due rows, renders branded emails, and delivers them over SMTP. It follows the indexjobs worker shape (poll ticker + LISTEN/NOTIFY wakeup, lease-based claiming, retry with exponential backoff). When SMTP is unconfigured or disabled the worker leaves rows pending without burning delivery attempts.
func (*Worker) Notify ¶
func (w *Worker) Notify()
Notify wakes the worker without waiting for the next poll tick. Safe to call from any goroutine; a flurry of calls coalesces into one wakeup.