1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
#[macro_export] macro_rules! jobs { ( $($id:ident,)* ) => { #[derive(Job)] enum __RobinJobs { $( $id, )* } $( pub struct $id; impl Job for $id { #[inline] fn name(&self) -> JobName { __RobinJobs::$id.name() } #[inline] fn perform(&self, args: &Args, con: &WorkerConnection) -> JobResult { __RobinJobs::$id.perform(args, con) } } impl $id { #[allow(dead_code)] #[inline] pub fn perform_now<A: Serialize>( args: A, con: &WorkerConnection, ) -> RobinResult<()> { $id.perform_now(args, con) } #[allow(dead_code)] #[inline] pub fn perform_later<A: Serialize>( args: A, con: &WorkerConnection, ) -> RobinResult<()> { $id.perform_later(args, con) } } )* } } #[macro_export] macro_rules! robin_establish_connection { ($config:expr) => ( robin::connection::establish($config.clone(), jobs::lookup_job) ) } #[macro_export] macro_rules! robin_boot_worker { ($config:expr) => ( robin::worker::boot(&$config.clone(), jobs::lookup_job); ) }