Documentation
¶
Overview ¶
Package outbox is the durable queue between smtp.Send and the relay: gopherex/pg-outbox over the service's store. Enqueue joins the caller's transaction; every replica runs the relay, which hands claimed deliveries to the Publisher (the mailer) and retries or dead-letters by its answer.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// Concurrency bounds deliveries in flight per replica.
Concurrency int64 `json:"concurrency" schemapb:"default=4;gte=1;lte=64"`
// MaxAttempts before a delivery is dead.
MaxAttempts int64 `json:"max_attempts" schemapb:"default=10;gte=1;lte=100"`
// RetryMax bounds the backoff between attempts (1s doubling to it).
RetryMax time.Duration `json:"retry_max" schemapb:"default=10m"`
// Retention of sent deliveries; DeadRetention of dead ones.
Retention time.Duration `json:"retention" schemapb:"default=72h"`
DeadRetention time.Duration `json:"dead_retention" schemapb:"default=168h"`
}
Config of the queue.
type Delivery ¶
type Delivery struct {
ID string `json:"id"`
Account string `json:"account"`
From string `json:"from"`
Caller string `json:"caller,omitempty"`
Message mail.Message `json:"message"`
}
Delivery is one queued mail: the message as validated, the account it goes through and who asked.
type Outbox ¶
Outbox is the component owning the relay.
func New ¶
func New(parent deps.Scope, cfg Config, st deps.Dependency[*store.Store], pub Publisher, instance string) *Outbox
New creates the queue under parent; the relay runs once the store is provided.
type Publisher ¶
type Publisher interface {
Deliver(ctx context.Context, d Delivery, attempt int) error
// Dead is told once a delivery exhausted its attempts.
Dead(ctx context.Context, d Delivery, attempts int, lastError string)
}
Publisher delivers one claimed delivery; see pg-outbox's outcomes (Permanent, Discard) for how its error is read.