Skip to main content

oxidite_queue/
lib.rs

1/// Job types and traits
2pub mod job;
3/// Queue backends and the Queue type
4pub mod queue;
5/// Worker for processing jobs
6pub mod worker;
7/// Queue statistics
8pub mod stats;
9
10/// Re-export of [`Job`], [`JobStatus`], [`JobResult`]
11pub use job::{Job, JobStatus, JobResult};
12/// Re-export of [`Queue`], [`QueueBackend`], [`MemoryBackend`]
13pub use queue::{Queue, QueueBackend, MemoryBackend};
14/// Redis queue backend
15pub mod redis;
16/// Re-export of [`RedisBackend`]
17pub use crate::redis::RedisBackend;
18/// PostgreSQL queue backend
19pub mod postgres;
20/// Re-export of [`PostgresBackend`]
21pub use crate::postgres::PostgresBackend;
22/// Re-export of [`Worker`]
23pub use worker::Worker;
24/// Re-export of [`QueueStats`], [`StatsTracker`]
25pub use stats::{QueueStats, StatsTracker};
26
27use thiserror::Error;
28
29/// Queue errors
30#[derive(Error, Debug)]
31pub enum QueueError {
32    /// Serialization error
33    #[error("Serialization error: {0}")]
34    SerializationError(#[from] serde_json::Error),
35    
36    /// Job execution failure
37    #[error("Job failed: {0}")]
38    JobFailed(String),
39    
40    /// Queue is at capacity
41    #[error("Queue full")]
42    QueueFull,
43    
44    /// Backend-specific error
45    #[error("Backend error: {0}")]
46    BackendError(String),
47}
48
49/// Queue result type alias
50pub type Result<T> = std::result::Result<T, QueueError>;