Expand description
In-app persistent queue
This crate implements a job queue for monolithic applications that persists across application restarts.
Thanks to the typetag
crate, your Job
s can use any serializable data type.
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct MyJob {
message: String
}
#[typetag::serde]
#[async_trait::async_trait]
impl Job for MyJob {
async fn run(&mut self, _: Arc<AppQueue>) -> Result<()> {
println!("{}", self.message);
Ok(())
}
}
#[tokio::main]
async fn main() -> Result<()> {
let queue = AppQueue::new("/tmp/queue.db").await?;
let job = MyJob {
message: "Hello, world!".into()
};
queue.add_job(Box::new(job)).await?;
queue.run_job_workers_default();
Ok(())
}
Structs§
Traits§
- Job
- Queued Job interface
Type Aliases§
- Never
- The Never
!
type. Can’t be created. Indicates that the function will never return.