nest_rs_queue/lib.rs
1//! The open queue contract for nestrs.
2//!
3//! `nestrs-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//! `nestrs-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//! `nestrs-<storage>` (e.g. SQS, NATS, in-memory) depends on this crate
15//! directly — see this crate's README for the extension contract.
16
17mod consumer;
18mod inventory;
19mod processor;
20mod producer;
21
22pub use consumer::JobConsumer;
23pub use inventory::{JobHandler, ProcessMethod, ProcessorMeta, WIRE_FORMAT_VERSION};
24pub use processor::{FromContainer, Job, Processor};
25pub use producer::{JobProducer, JobProducerExt, QueueBackend};
26
27// Re-export `async_trait` so backends and macros don't need to depend on it
28// directly to implement the async traits this crate defines.
29pub use async_trait::async_trait;
30
31// The `inventory::collect!` lives in `inventory.rs` — the registry is the
32// open seam between the `#[process]` macro emission and any backend that
33// drains it at boot.
34
35// `#[processor]`-generated code names `::nest_rs_queue::ProcessMethod`,
36// `::nest_rs_queue::JobHandler`, and `::nest_rs_queue::serde_json::*`, so this
37// crate re-exports both the macro and `serde_json` — keeping the macro free
38// of any backend dependency and letting the call site reach the macro
39// through `nest_rs_queue::processor` regardless of which backend integration
40// (nestrs-redis, …) the app imports.
41#[doc(hidden)]
42pub use serde_json;
43
44// Re-exported for `#[processor]`-generated code that emits a `warn!` for
45// unversioned legacy payloads. Keeps the macro free of any extra dependency
46// at the call site.
47#[doc(hidden)]
48pub use tracing;
49
50pub use nest_rs_queue_macros::processor;