Skip to main content

Crate nest_rs_queue

Crate nest_rs_queue 

Source
Expand description

The open queue contract for nestrs.

nest-rs-queue defines what every queue backend must agree on: the Job marker, the Processor trait, the ProcessMethod inventory entry the #[processor] macro submits, and the three pluggable seams a backend implements — QueueBackend, JobProducer, JobConsumer.

The first-class backend is Redis (via apalis-redis), shipped as nest-rs-redis. Application code keeps writing nest_rs_queue::* for the abstractions — the #[processor] macro, Job, Processor, ProcessMethod, JobProducer — and reaches for nest_rs_redis::* only when it needs the Redis-specific types (the QueueConnection producer, the QueueWorker transport, the activation modules). A third-party nest-rs-<storage> (e.g. SQS, NATS, in-memory) depends on this crate directly — see this crate’s README for the extension contract.

Structs§

ProcessMethod
Link-time inventory entry submitted by #[processor] for each #[process]-tagged method. A JobConsumer drains this registry at boot and filters by ReachableProviders so a method on a provider not reachable from the app’s module tree is skipped with a boot warn (the consumer logs it, so leftover code stays visible).
ProcessorMeta
Runtime metadata for one consumer, surfaced via DiscoveryService for the classic struct-level #[processor] form. New code uses ProcessMethod directly; this type remains for backends that consume ProcessorMeta via DiscoveryService::meta::<ProcessorMeta>().

Enums§

QueueError
A failure enqueuing a job through a JobProducer (or the push convenience over it).

Constants§

WIRE_FORMAT_VERSION
Wire-format version every backend wraps jobs with on push and unwraps on dispatch. Bumping it lets a #[processor] handler reject payloads from a newer release (rolling-deploy safety) instead of misinterpreting bytes.

Traits§

FromContainer
Queue analog of #[injectable]’s from_container, expressed as a trait so a backend can build any processor generically from the container.
Job
JSON-round-trippable + Clone (retry keeps a copy) + cross-task safe.
JobConsumer
Drains a list of #[process] methods until cancellation. One per app — the Transport a queue backend contributes typically wraps a JobConsumer and forwards the cancellation token.
JobProducer
Backend-agnostic producer: push a JSON-serialized job onto a named queue. Concrete backends implement this; typed pushes are a convenience built on top via JobProducerExt.
JobProducerExt
Typed-push convenience over any JobProducer. Lives as an extension trait so the producer trait stays object-safe (Arc<dyn JobProducer>).
Processor
A returned Err marks the job failed; the backend retries up to the #[process(retries = N)] budget.
QueueBackend
A queue backend, identified by name for boot diagnostics. The actual runtime work happens through JobProducer (enqueue) and JobConsumer (drain ProcessMethod and dispatch). A backend’s module typically:
QueueName
The type-level identity of a queue: its wire name plus the Job payload it carries. Implemented by the queue macro on a unit struct living beside the payload at the feature port:

Type Aliases§

JobHandler
Type-erased async job handler the #[processor] macro emits for each #[process] method. Backends invoke it with a JSON payload pulled off their wire; the closure deserializes to the user’s job type, resolves the provider from the container, and dispatches.

Attribute Macros§

async_trait
processor
Orchestrator on an #[injectable] provider’s impl block. Each method tagged with #[process(queue = "...", concurrency, retries)] becomes a queue consumer the QueueWorker spawns at boot.
queue
Stamp a unit struct with a compile-time queue identity — its wire name and the Job payload it carries — by implementing QueueName. Lives beside the payload at the feature port; both the producer (push_to::<Q>) and the consumer (#[process(queue = Q)]) name the type, so a typo’d name or a mismatched payload is a compile error, not a job that silently never drains.