Something went wrong. Try again.
wip outbox library design
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829// Package outpost implements the transactional outbox pattern.//// The model has three seams://// - Appender persists messages as part of a unit of work owned by a backend// adapter -- a SQL transaction, a CQL batch, a Kafka transaction, or// nothing at all. Emit encodes a value as JSON and appends it through one.// - Store is the relay's view of a backend: leased delivery, completion,// failure, and abandonment of claimed messages.// - Producer is what the relay does with a claimed message: send the email,// publish to a broker, invoke a handler. ProducerFunc adapts a function.//// Handlers are registered on a Dispatcher by message name and can be fed by// any producer: a relay using ProducerFunc(d.Dispatch), a broker consumer, or// a poller process. A handler receives the decoded payload and can read the// message metadata -- its ID, grouping key, headers, and delivery attempt --// with InfoFromContext.//// Guarantees: at-least-once delivery; retries with backoff, spread so that// independent workers do not retry in lockstep; permanent failures and// exhausted attempts are abandoned rather than retried; the lease duration is// derived from batch size, worker count, and delivery timeout so a claimed// batch cannot outlive its lease.//// Non-goals: exactly-once delivery; ordering across messages (a single relay// with Workers=1 processes claims in store order, and nothing more); codecs// other than JSON; deferred delivery acknowledgements.package outpost