Skip to main content

nest_rs_queue/
lib.rs

1//! The open queue contract for nestrs.
2//!
3//! `nest-rs-queue` defines **what every queue backend must agree on**: the
4//! [`Job`] marker, the [`Processor`] trait, the [`ProcessMethod`] inventory
5//! entry the `#[processor]` macro submits, and the three pluggable seams a
6//! backend implements — [`QueueBackend`], [`JobProducer`], [`JobConsumer`].
7//!
8//! The first-class backend is **Redis** (via apalis-redis), shipped as
9//! `nest-rs-redis`. Application code keeps writing `nest_rs_queue::*` for the
10//! abstractions — the `#[processor]` macro, `Job`, `Processor`,
11//! `ProcessMethod`, `JobProducer` — and reaches for `nest_rs_redis::*` only
12//! when it needs the Redis-specific types (the `QueueConnection` producer,
13//! the `QueueWorker` transport, the activation modules). A third-party
14//! `nest-rs-<storage>` (e.g. SQS, NATS, in-memory) depends on this crate
15//! directly — see this crate's README for the extension contract.
16mod consumer;
17mod error;
18mod inventory;
19mod processor;
20mod producer;
21mod queue_name;
22
23pub use consumer::JobConsumer;
24pub use error::QueueError;
25pub use inventory::{JobHandler, ProcessMethod, ProcessorMeta, WIRE_FORMAT_VERSION};
26pub use processor::{FromContainer, Job, Processor};
27pub use producer::{JobProducer, JobProducerExt, QueueBackend};
28pub use queue_name::QueueName;
29
30// Re-export `async_trait` so backends and macros don't need to depend on it
31// directly to implement the async traits this crate defines.
32pub use async_trait::async_trait;
33
34// The `inventory::collect!` lives in `inventory.rs` — the registry is the
35// open seam between the `#[process]` macro emission and any backend that
36// drains it at boot.
37
38// `#[processor]`-generated code names `::nest_rs_queue::ProcessMethod`,
39// `::nest_rs_queue::JobHandler`, and `::nest_rs_queue::serde_json::*`, so this
40// crate re-exports both the macro and `serde_json` — keeping the macro free
41// of any backend dependency and letting the call site reach the macro
42// through `nest_rs_queue::processor` regardless of which backend integration
43// (nest-rs-redis, …) the app imports.
44#[doc(hidden)]
45pub use serde_json;
46
47// Re-exported for `#[processor]`-generated code that emits a `warn!` for
48// unversioned legacy payloads. Keeps the macro free of any extra dependency
49// at the call site.
50#[doc(hidden)]
51pub use tracing;
52
53pub use nest_rs_queue_macros::{processor, queue};