Trait batch::Task [] [src]

pub trait Task: DeserializeOwned + Serialize {
    fn name() -> &'static str;
fn exchange() -> &'static str;
fn routing_key() -> &'static str;
fn retries() -> u32;
fn timeout() -> Option<Duration>; }

An executable task and its related metadata (name, queue, timeout, etc.)

In most cases, you should be deriving this trait instead of implementing it manually yourself.

Examples

Using the provided defaults:

#[macro_use]
extern crate batch;
extern crate serde;
#[macro_use]
extern crate serde_derive;

#[derive(Deserialize, Serialize, Task)]
#[task_routing_key = "emails"]
struct SendConfirmationEmail;

Overriding the provided defaults:

#[macro_use]
extern crate batch;
extern crate serde;
#[macro_use]
extern crate serde_derive;

struct App;

#[derive(Deserialize, Serialize, Task)]
#[task_name = "batch-rs:send-password-reset-email"]
#[task_routing_key = "emails"]
#[task_timeout = "120"]
#[task_retries = "0"]
struct SendPasswordResetEmail;

Required Methods

A should-be-unique human-readable ID for this task.

The exchange the task will be published to.

The routing key associated to this task.

The number of times this task must be retried in case of error.

An optional duration representing the time allowed for this task's handler to complete.

Implementors