Crate aj

Source
Expand description

Aj is a simple, flexible, and feature-rich background job processing library for Rust, backed by Actix (Actor Model).

use std::time::Duration;

use aj::job;
use aj::{export::core::actix_rt::time::sleep, main, 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}");
}

#[main]
async fn main() {
   // Start AJ engine
   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
   sleep(Duration::from_secs(1)).await;
}

More examples Features

Re-exports§

pub use aj_core::chrono;

Modules§

backend
job
job_plugin
mem
WARNING: Mem is purposing for testing or small application. It doesn’t support Persistent Mode.
queue
redis
retry

Structs§

AJ
ChangeStatus
Job
JobContext
JobPluginWrapper
PluginCenter
RegisterPlugin
RunHook
WorkQueue

Enums§

Error

Traits§

BackgroundJob
Executable
JobPlugin
Implement Plugin to catch job hook event

Attribute Macros§

async_trait
job
main
Marks async entry-point function to be executed by Actix system.

Derive Macros§

BackgroundJob