Crate batch [−] [src]
Batch is a distributed task queue library.
This library allows you to send a task to a RabbitMQ broker, so that a worker will be able
to pull it and execute the associated handler. It leverages the futures
and tokio-core
crates to provide asynchronous I/O operations.
Example
#[macro_use] extern crate batch; extern crate futures; extern crate serde; #[macro_use] extern crate serde_derive; extern crate tokio_core; use batch::{exchange, job, ClientBuilder}; use futures::Future; use tokio_core::reactor::Core; #[derive(Serialize, Deserialize, Task)] #[task_routing_key = "hello-world"] struct SayHello { to: String, } fn main() { let mut core = Core::new().unwrap(); let handle = core.handle(); let exchanges = vec![ exchange("batch.examples"), ]; let client = ClientBuilder::new() .connection_url("amqp://localhost/%2f") .exchanges(exchanges) .handle(handle) .build(); let send = client.and_then(|client| { let task = SayHello { to: "Ferris".into(), }; job(task).exchange("batch.example").send(&client) }); core.run(send).unwrap(); }
Structs
Client |
The |
ClientBuilder |
A builder to ease the construction of |
Error |
|
ExchangeBuilder |
A builder for |
Query |
A |
QueueBuilder |
A builder for |
Worker |
Long-running worker polling tasks from the given |
WorkerBuilder |
A builder to ease the construction of |
Traits
Perform |
The |
Task |
An executable task and its related metadata (name, queue, timeout, etc.) |
Functions
exchange |
Shorthand to create a new |
job |
Shorthand to create a new |
queue |
Shorthand to create a new |