Expand description
Aj is a simple, flexible, and feature-rich background job processing library for Rust.
§Quick Start
ⓘ
use std::time::Duration;
use aj::job;
use aj::AJ;
#[job]
fn hello(name: String) {
println!("Hello {name}");
}
#[job]
async fn async_hello(name: String) {
// We support async fn as well
println!("Hello async, {name}");
}
#[tokio::main]
async fn main() {
// Start AJ engine with in-memory backend
AJ::quick_start();
// Wait the job is registered in AJ
let _ = hello::run("Rodgers".into()).await;
// Or fire and forget it
let _ = async_hello::just_run("AJ".into());
// Sleep 1 ms to view the result from job
tokio::time::sleep(Duration::from_secs(1)).await;
}§Feature Flags
redis- Enables Redis backend support for production use with persistence
# Enable Redis backend
aj = { version = "0.7.2", features = ["redis"] }§Using Redis Backend
When the redis feature is enabled:
ⓘ
use aj::redis::Redis;
use aj::AJ;
AJ::start(Redis::new("redis://localhost:6379"));Re-exports§
pub use aj_core::chrono;
Modules§
Structs§
Enums§
Traits§
- Background
Job - Executable
- JobPlugin
- Implement Plugin to catch job hook event