17 releases
| new 0.1.300 | Feb 6, 2026 |
|---|---|
| 0.1.292 | Feb 6, 2026 |
| 0.1.233 | Jan 30, 2026 |
#2555 in HTTP server
37KB
669 lines
rustapi-jobs
Lens: "The Workhorse"
Philosophy: "Fire and forget, with reliability guarantees."
Background job processing for RustAPI. Long-running tasks shouldn't block HTTP requests.
Quick Start
// Define a job
#[derive(Serialize, Deserialize)]
struct EmailJob { to: String }
// Enqueue it
queue.push(EmailJob { to: "alice@example.com" }).await;
Backends
| Backend | Use Case |
|---|---|
| Memory | Development and testing |
| Redis | High throughput persistence |
| Postgres | Transactional reliability (ACID) |
Reliability Features
- Exponential Backoff: Automatic retries for failing jobs
- Dead Letter Queue: Poison jobs are isolated for manual inspection
- At-Least-Once Delivery: Jobs are not lost if a worker crashes
- Scheduling: Cron-like recurring tasks
Full Example
use rustapi_jobs::{Job, JobContext};
#[derive(Serialize, Deserialize)]
struct SendEmail {
to: String,
content: String,
}
#[async_trait]
impl Job for SendEmail {
const NAME: &'static str = "send_email";
async fn run(&self, _ctx: JobContext) -> Result<()> {
// Send the email...
Ok(())
}
}
// Enqueue
queue.push(SendEmail { ... }).await?;
Dependencies
~9–29MB
~302K SLoC