| Crates.io | aj |
| lib.rs | aj |
| version | 0.7.1 |
| created_at | 2023-12-10 09:48:59.537778+00 |
| updated_at | 2025-02-03 06:08:29.189694+00 |
| description | Background Job based on Actix |
| homepage | |
| repository | https://github.com/cptrodgers/aj |
| max_upload_size | |
| id | 1064109 |
| size | 39,161 |
Aj is a simple, customizable, and feature-rich background job processing library for Rust. It can work with any runtime by running new actix-rt in a separated thread if it detects that an actix-rt runtime is not present.
aj = "0.7.0"
serde = { version = "1.0.64", features = ["derive"] } # Serialize and deserialize the job
actix-rt = "2.2" # Actor model runtime engine
use aj::job;
#[job]
async fn hello(name: String) {
println!("Hello {name}");
}
#[aj::main]
async fn main() {
// AJ will be backed by run in-memory backend.
// If you wish to use redis as the backend for aj.
// AJ::start(aj::Redis::new("redis://localhost:6379"));
AJ::quick_start();
// Fire and forget the job. No gruantee job is queued
hello::just_run("Rodgers".into());
// Or waiting job is queued
hello::run("AJ".into()).await;
// Sleep 1 sec to view the result from job (if you want to wait the job run)
// sleep(Duration::from_secs(1)).await;
}