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