2 unstable releases
| 0.3.0 | Aug 19, 2025 |
|---|---|
| 0.2.0 | Aug 17, 2025 |
#5 in #elif
22 downloads per month
Used in elif-email
1MB
18K
SLoC
elif-queue
Background job queue system for the elif.rs framework.
Features
- Multi-backend support: Memory and Redis queue backends
- Job persistence: Reliable job storage and recovery
- Priority queuing: Support for job priorities and delays
- Async-first: Built for modern async Rust applications
- Type-safe: Generic job definitions with serialization support
- Retry logic: Built-in failure handling and retry mechanisms
Quick Start
use elif_queue::{Queue, MemoryBackend, QueueConfig, Job, JobResult};
use std::time::Duration;
use serde::{Serialize, Deserialize};
use async_trait::async_trait;
#[derive(Debug, Clone, Serialize, Deserialize)]
struct EmailJob {
to: String,
subject: String,
body: String,
}
#[async_trait]
impl Job for EmailJob {
async fn execute(&self) -> JobResult<()> {
// Send email logic here
println!("Sending email to: {}", self.to);
Ok(())
}
fn job_type(&self) -> &'static str {
"email"
}
}
// Create a memory-based queue
let queue = Queue::new(MemoryBackend::new(QueueConfig::default()));
// Enqueue a job
let job = EmailJob {
to: "user@example.com".to_string(),
subject: "Hello".to_string(),
body: "Hello, World!".to_string(),
};
queue.enqueue(job, None).await.unwrap();
// Process jobs
if let Some(job_entry) = queue.dequeue().await.unwrap() {
let result = job_entry.execute::<EmailJob>().await;
queue.complete(job_entry.id(), result).await.unwrap();
}
Dependencies
~9–22MB
~272K SLoC