@theconduit/provider-outbox
v0.1.1
Published
SQL-backed transactional outbox for Conduit: durable enqueue, relay scheduler with retries and ordering hooks, adapters for PostgreSQL, MySQL, and SQLite, plus SQL migrations for operations tables.
Downloads
16
Maintainers
Readme
@theconduit/provider-outbox
Transactional outbox provider, relay, schedulers, adapters, and SQL migrations for durable asynchronous dispatch.
Install
pnpm add @theconduit/provider-outboxHighlights
OutboxProviderenqueues records in durable storage.OutboxRelayclaims pending records and executes handlers.OutboxRelaySchedulerruns relay polling loop.- Partition-aware ordering (
createOrderedOutboxRelay). - Adapters:
InMemoryOutboxAdapter,PgOutboxAdapter,MySqlOutboxAdapter,SqliteOutboxAdapter. - Built-in SQL migrations via
OUTBOX_SQL_MIGRATIONS.
Quick start
import { ConduitBuilder } from "@theconduit/core";
import {
InMemoryOutboxAdapter,
OutboxProvider,
OutboxDLQManager,
OutboxRelayScheduler,
createOrderedOutboxRelay,
createPayloadPartitionKeyResolver
} from "@theconduit/provider-outbox";
const adapter = new InMemoryOutboxAdapter();
const provider = new OutboxProvider(adapter, {
partition_key_resolver: createPayloadPartitionKeyResolver({
fallback_to_operation_id: true
})
});
const dlq = new OutboxDLQManager();
const relay = createOrderedOutboxRelay(adapter, provider, {
batch_size: 100,
max_parallelism: 8,
dlq_manager: dlq
});
const scheduler = new OutboxRelayScheduler(relay, {
poll_interval_ms: 100,
on_error: (error) => {
console.error("relay error", error);
}
});
const bus = new ConduitBuilder()
.registerProvider(provider)
.withDlqManager(dlq)
.build();
scheduler.start();
// ...on shutdown
await scheduler.stop();Migrations
import { OUTBOX_SQL_MIGRATIONS } from "@theconduit/provider-outbox";
const postgresMigrationChunks = OUTBOX_SQL_MIGRATIONS.postgres;Exports
- Provider and relay:
OutboxProvider,OutboxRelay,OutboxRelayScheduler - Partition helpers:
createOrderedOutboxRelay,createPayloadPartitionKeyResolver - DLQ:
OutboxDLQManager - DB adapters:
InMemoryOutboxAdapter,PgOutboxAdapter,MySqlOutboxAdapter,SqliteOutboxAdapter - SQL helpers:
OUTBOX_SQL_MIGRATIONS
Related docs
docs/guides/outbox-provider.mddocs/guides/idempotency-patterns.mddocs/guides/migration-monolith-to-services.md
