use crate::Error;
use async_trait::async_trait;
const COMMON_QUEUE: &str = "default";
const TRIES: i16 = 1;
const TIMEOUT: i16 = 300;
#[typetag::serde(tag = "type")]
#[async_trait]
pub trait Job: Send + Sync {
async fn handle(&self) -> Result<(), Error>;
fn queue(&self) -> String {
COMMON_QUEUE.to_string()
}
fn tries(&self) -> i16 {
TRIES
}
fn timeout(&self) -> i16 {
TIMEOUT
}
fn backoff(&self, attempt: u32) -> u32 {
u32::pow(2, attempt)
}
async fn failed(&self, _err: Error) -> Result<(), Error> {
Ok(())
}
}