Skip to main content

queuey_core/
lib.rs

1//! Core abstractions for `queuey`.
2//!
3//! This crate is transport-agnostic. It defines:
4//!
5//! * [`QueueSet`]: implemented (usually via `#[derive(Queues)]`) by an enum whose
6//!   variants are the queues of an application.
7//! * [`Job`]: implemented (usually via `#[derive(Job)]`) by a serializable payload
8//!   type. A job statically knows which queue (variant) it belongs to.
9//! * [`JobHandler`]: user code that processes one job type.
10//! * [`Backend`]: a message transport (RabbitMQ, in-memory, ...).
11//! * [`Producer`] / [`Worker`]: the runtime that ties everything together.
12//! * [`RetryPolicy`] / [`Backoff`]: optional (exponential) retry configuration.
13//! * Deferral: a handler returns [`JobError::Deferred`] (or a producer calls
14//!   [`Producer::defer`]) to park a job for an exact delay and have it come back
15//!   *ahead* of the backlog, at [`QueueConfig::max_priority`], without spending an
16//!   attempt. The motivating case is an API answering `429` with `Retry-After`.
17//!
18//! Module structure and public API below is the *contract* shared by the macro crate
19//! and the backend crates. Keep signatures stable; extend rather than change.
20
21#![forbid(unsafe_code)]
22#![warn(missing_docs)]
23
24pub mod backend;
25pub mod envelope;
26pub mod error;
27pub mod handler;
28pub mod job;
29pub mod memory;
30pub mod producer;
31pub mod queue;
32pub mod retry;
33#[cfg(test)]
34pub(crate) mod test_support;
35pub mod worker;
36
37pub use backend::{Backend, Delivery, DeliveryStream};
38pub use envelope::Envelope;
39pub use error::{Error, JobError, Result};
40pub use handler::{FnHandler, JobContext, JobHandler};
41pub use job::Job;
42pub use memory::MemoryBackend;
43pub use producer::Producer;
44pub use queue::{DEFAULT_MAX_PRIORITY, QueueConfig, QueueSet};
45pub use retry::{Backoff, RetryDecision, RetryPolicy};
46pub use worker::{Worker, WorkerBuilder, WorkerHandle};
47
48/// Re-exports needed by generated code from `queuey-macros`.
49/// Not part of the stable public API.
50#[doc(hidden)]
51pub mod __private {
52    pub use serde;
53    pub use serde_json;
54}