1#![allow(clippy::field_reassign_with_default)]
2
3#[macro_use]
4extern crate log;
5#[macro_use]
6extern crate serde_with;
7
8pub mod aj;
9pub mod backend;
10pub mod error;
11pub mod job;
12pub mod plugin;
13pub mod queue;
14pub mod util;
15
16pub use aj::*;
17pub use backend::*;
18pub use error::*;
19pub use job::*;
20pub use plugin::*;
21pub use queue::*;
22pub use util::*;
23
24pub use async_trait;
26pub use chrono;
27pub use cron;
28pub use serde;
29
30use serde::{de::DeserializeOwned, Serialize};
31
32impl<M> Job<M>
33where
34 M: BackgroundJob
35 + Executable
36 + Unpin
37 + Send
38 + Sync
39 + Clone
40 + Serialize
41 + DeserializeOwned
42 + 'static,
43{
44 pub async fn run(self) -> Result<String, Error> {
46 AJ::add_job(self, M::queue_name()).await
47 }
48
49 pub fn just_run(self) {
51 if let Some(aj_ref) = get_aj_address() {
52 let job = self;
53 let queue_name = M::queue_name().to_string();
54 tokio::spawn(async move {
56 let _ = aj_ref.tell(JustRunJob { job, queue_name }).await;
57 });
58 }
59 }
60}