Skip to content

Instantly share code, notes, and snippets.

@zupzup
Created March 18, 2020 14:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zupzup/f65ce0e9c846ecb5c2b710adca9caa59 to your computer and use it in GitHub Desktop.
Save zupzup/f65ce0e9c846ecb5c2b710adca9caa59 to your computer and use it in GitHub Desktop.
some_gist
#[derive(Clone)]
pub struct JobContext {
pub db_pool: DBPool,
pub redis_pool: RedisPool,
}
pub trait Job {
fn run(&self, ctx: &JobContext) -> JobResult;
fn get_interval(&self) -> Duration;
fn get_name(&self) -> &'static str;
fn get_sync_key(&self) -> &'static str;
fn box_clone(&self) -> BoxedJob;
}
impl Clone for Box<dyn Job> {
fn clone(&self) -> Box<dyn Job> {
self.box_clone()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment