better-effect-mq
Storage-neutral durable jobs, flows, workers and testing for better-effect.
better-effect-mq is the storage-neutral core for durable jobs, optional
parent/child composition, and Layer-first Workers. A queue is a namespace,
a Job is an immutable versioned producer/handler identity, and a JobStore
is the atomic persistence seam. A Worker runs handlers over one existing
better-effect Runtime; it does not create a second Runtime or choose a
database.
For application boundaries, start with a provider-backed schema: the recommended
path is Zod 4 through better-effect-schema, connected
to a Job with Codec.standardSchema. This validates persisted payloads and
results at the edge while keeping the core provider-neutral. The trusted JSON
escape hatch is available for values
that are already plain and trusted—such as a small internal payload—but is not
the default for HTTP, queue or database-boundary examples.
Read the guide that matches the operation you are implementing:
- Introduction — the queue and delivery model.
- Defining Jobs — queue, identity, codecs and versions.
- Enqueueing — producer programs, admin operations and idempotency.
- Workers — handler inference and the Worker lifecycle.
- Flows — durable parent/child fan-out and result collection.
- Retries and timeouts — durable backoff and cooperative limits.
- Cancellation and shutdown — AbortSignal and graceful ownership.
- Idempotency and delivery — at-least-once processing.
- Stores and named stores — adapters and bindings.
- Testing —
TestJobStore, real Workers and deterministic clocks. - Writing a storage adapter — the advanced provider boundary.
- Operations and observability — polling, events and production checks.
Storage adapters are separate packages. The current adapter family includes
PostgreSQL, Redis/Valkey, MongoDB, SQLite and MySQL; each provides the same
JobStore contract and documents its migrations, client ownership and
transaction boundaries in the adapter guides.
The storage-neutral
better-effect-mq-outbox
package provides prepared outbox records, routing and a Layer-owned publisher.
The public package surface is exported from better-effect-mq; runner-neutral
helpers are under better-effect-mq/testing. The package uses only
better-effect and better-result as its core foundations and contains no
SQL, Redis or other driver.