Crates.io | oxanus |
lib.rs | oxanus |
version | 0.3.39 |
created_at | 2025-05-21 21:35:45.812371+00 |
updated_at | 2025-08-21 23:49:32.725602+00 |
description | A simple & fast job queue system. |
homepage | |
repository | https://github.com/oxanus/oxanus |
max_upload_size | |
id | 1684304 |
size | 197,675 |
Oxanus is job processing library written in Rust doesn't suck (or at least sucks in a completely different way than other options).
Oxanus goes for simplity and depth over breadth. It only aims support single backend with simple flow.
use oxanus::{Worker, Queue, Context, Config, Storage};
use serde::{Serialize, Deserialize};
// Define your worker
#[derive(Debug, Serialize, Deserialize)]
struct MyWorker {
data: String,
}
#[async_trait::async_trait]
impl Worker for MyWorker {
type Context = MyContext;
type Error = MyError;
async fn process(&self, ctx: &Context<MyContext>) -> Result<(), MyError> {
// Process your job here
Ok(())
}
}
// Define your queue
#[derive(Serialize)]
struct MyQueue;
impl Queue for MyQueue {
fn to_config() -> QueueConfig {
QueueConfig::as_static("my_queue")
}
}
// Define your context
struct MyContext {}
// Run your worker
async fn run_worker() -> Result<(), OxanusError> {
let ctx = Context::value(MyContext {});
let storage = Storage::builder().from_env()?.build()?;
let config = Config::new(&storage)
.register_queue::<MyQueue>()
.register_worker::<MyWorker>();
// Enqueue some jobs
storage.enqueue(MyQueue, MyWorker { data: "hello".into() }).await?;
// Run the worker
oxanus::run(config, ctx).await?;
Ok(())
}
For more detailed usage examples, check out the examples directory.
Workers are the units of work in Oxanus. They implement the [Worker
] trait and define the processing logic.
Queues are the channels through which jobs flow. They can be:
Each queue can have its own:
The [Storage
] trait provides the interface for job persistence. It handles:
The context provides shared state and utilities to workers. It can include:
Configuration is done through the [Config
] builder, which allows you to:
Oxanus uses a custom error type [OxanusError
] that covers all possible error cases in the library.
Workers can define their own error type that implements std::error::Error
.