bullmq/lib.rs
1#![warn(missing_docs)]
2
3//! # BullMQ - Rust Port
4//!
5//! A powerful, fast, and robust job queue backed by Redis.
6//!
7//! This crate provides a Rust implementation of the BullMQ job queue system,
8//! fully compatible with the Node.js and Elixir implementations.
9//!
10//! ## Architecture
11//!
12//! - [`Queue`] - Add jobs to a queue and manage queue state.
13//! - [`Worker`] - Process jobs from a queue with configurable concurrency.
14//! - [`Job`] - Represents a unit of work in the queue.
15//!
16//! ## Example
17//!
18//! ```rust,no_run
19//! use bullmq::{Queue, Worker, Job, QueueOptions, WorkerOptions};
20//! use std::sync::Arc;
21//!
22//! #[tokio::main]
23//! async fn main() -> Result<(), bullmq::Error> {
24//! let queue = Queue::new("my-queue", QueueOptions::default()).await?;
25//!
26//! queue.add("my-job", serde_json::json!({"foo": "bar"}), None).await?;
27//!
28//! let worker = Worker::new("my-queue", Arc::new(|job: Job, _token| Box::pin(async move {
29//! println!("Processing job: {}", job.id());
30//! Ok(serde_json::Value::Null)
31//! })), WorkerOptions::default()).await?;
32//!
33//! Ok(())
34//! }
35//! ```
36
37/// Error types for BullMQ operations.
38pub mod error;
39/// FlowProducer — atomically add trees of dependent jobs (flows).
40pub mod flow_producer;
41/// Job representation and lifecycle management.
42pub mod job;
43/// Job Scheduler — repeatable/cron-based job scheduling.
44pub mod job_scheduler;
45/// Redis key generation for queue data structures.
46pub mod keys;
47/// Configuration options for queues, workers, and jobs.
48pub mod options;
49/// Queue management and job submission.
50pub mod queue;
51/// Cross-process queue event listener (stream-based).
52pub mod queue_events;
53/// Redis connection handling.
54pub mod redis_connection;
55/// Lua script registry and execution.
56pub mod scripts;
57/// Shared types: job state, progress, backoff strategies.
58pub mod types;
59/// Worker implementation for processing jobs...
60pub mod worker;
61
62pub use error::Error;
63pub use flow_producer::{
64 FlowJob, FlowOpts, FlowProducer, FlowProducerOptions, FlowQueueOptions, GetFlowOpts, JobNode,
65};
66pub use job::Job;
67pub use keys::QueueKeys;
68pub use options::{
69 BackoffStrategyFn, DeduplicationOptions, JobOptions, MetricsOptions, ParentOpts, QueueOptions,
70 RateLimiterOptions, WorkerOptions,
71};
72pub use queue::JobCountRecorder;
73pub use queue::Queue;
74pub use queue_events::{QueueEvent, QueueEventEntry, QueueEvents, QueueEventsOptions};
75pub use types::{
76 DependenciesCount, DependenciesResult, JobProgress, JobState, Metrics, MetricsMeta, QueueMeta,
77 RetryOptions,
78};
79pub use worker::Worker;
80
81/// Result type alias for BullMQ operations.
82pub type Result<T> = std::result::Result<T, Error>;