Expand description
Transactional outbox primitives shared by every storage and transport adapter in the workspace.
The crate is split into two sides:
- Producer —
OutboxServicepersists new events into the outbox table, applying the configuredIdempotencyStrategyand optionally reserving the token through an externalIdempotencyStorageProvider. - Worker —
OutboxManager, constructed viaOutboxManagerBuilder, drives the processing loop: it waits for notifications, fetches pending rows, publishes each through aTransport, and runs a background garbage collector on the side.
Storage and transport backends live in sibling crates (outbox-postgres,
outbox-redis, outbox-kafka). This crate only defines the traits they
must satisfy.
§Features
sqlx— derivessqlx::Type/sqlx::FromRowon the domain types so storage adapters can map rows without manual conversion.dlq— enables the dead-letter-queue heap (seeDlqHeap); the worker then tracks per-event failure counts on every publish attempt.metrics— emitsoutbox.events_totalandoutbox.publish_duration_secondsvia themetricscrate.full— turns onsqlx,dlq, andmetricstogether.
§Getting started
Import the common types via the prelude module:
ⓘ
use outbox_core::prelude::*;Modules§
- prelude
- Curated set of re-exports for typical integrator code.
Structs§
- DlqEntry
- One entry tracked by [
DlqHeap]: an event id together with its current aggregated failure count. - Event
- A single outbox row representing one domain event to be published.
- EventId
- Primary key of an outbox row.
- Event
Type - Domain-level event name used by transports for routing (Kafka topic suffix, Redis stream key, etc).
- Idempotency
Token - Deduplication token attached to an
Event. - NoIdempotency
- No-op
IdempotencyStorageProviderthat accepts every token. - Outbox
Config - Runtime configuration shared by the producer and worker sides.
- Outbox
Manager - Long-running worker that publishes pending outbox events to the broker.
- Outbox
Manager Builder - Fluent builder that assembles an
OutboxManager. - Outbox
Service - Producer-side facade for writing outbox events.
- Payload
- Typed wrapper around the user’s domain event value.
Enums§
- Event
Status - Lifecycle stage of an outbox
Event. - Idempotency
Strategy - How an idempotency token is produced when a new event is written.
- Outbox
Error - Error categories produced by the outbox crate.
Traits§
- DlqHeap
- Tracks per-event publish failure counts for the dead-letter queue.
- Idempotency
Storage Provider - Async contract for reserving an idempotency token before an event is written.
- Outbox
Storage - Worker-side storage contract.
- Outbox
Writer - Producer-side storage contract.
- Transport
- Publishes a single
Eventto an external system.
Type Aliases§
- Idempotency
Deriver - Shared callback used by
IdempotencyStrategy::Customto derive an idempotency token from the event about to be written.