Module robin::macros
[−]
[src]
Contains the macros exported by Robin.
jobs!
Takes a comma separate list of struct names. Each struct will become a job that you can call
perform_now
or perform_later
on. You just have to implement a static method named perform
on each struct that does the actual work.
Example
#[macro_use] extern crate robin; #[macro_use] extern crate serde_derive; use robin::prelude::*; jobs! { SendPushNotification, } impl SendPushNotification { fn perform(args: SendPushNotificationArgs, _con: &WorkerConnection) -> JobResult { // Code for actually sending push notifications Ok(()) } } #[derive(Serialize, Deserialize, Debug)] pub struct SendPushNotificationArgs { device_id: String, platform: DevicePlatform, } #[derive(Serialize, Deserialize, Debug)] pub enum DevicePlatform { Ios, Android, }
robin_establish_connection!
Creates a new connection used to enqueued jobs, using the given config.
Example
#[macro_use] extern crate robin; #[macro_use] extern crate serde_derive; use robin::prelude::*; let config = Config::default(); let con = robin_establish_connection!(config)?; let args = SendPushNotificationArgs { device_id: "123".to_string(), platform: DevicePlatform::Android, }; SendPushNotification::perform_later(&args, &con)?;
robin_boot_worker!
Boots the worker which performs the jobs.
Example
#[macro_use] extern crate robin; #[macro_use] extern crate serde_derive; use robin::prelude::*; let config = Config::default(); robin_boot_worker!(config);