[−][src]Crate celery
A Rust implementation of Celery for producing and consuming asyncronous tasks with a distributed message queue.
Examples
Define tasks by decorating functions with the task
attribute:
use celery::TaskResult; #[celery::task] fn add(x: i32, y: i32) -> TaskResult<i32> { Ok(x + y) }
Then create a Celery
app with the app
macro and register your tasks with it:
let my_app = celery::app!( broker = AMQP { std::env::var("AMQP_ADDR").unwrap() }, tasks = [add], task_routes = [], );
The Celery app can be used as either a producer or consumer (worker). To send tasks to a
queue for a worker to consume, use the Celery::send_task
method:
my_app.send_task(add::new(1, 2)).await?;
And to act as worker and consume tasks sent to a queue by a producer, use the
Celery::consume
method:
my_app.consume().await?;
Re-exports
pub use error::TaskResultExt; |
pub use task::TaskResult; |
Modules
broker | The broker is an integral part of a |
error | Error types. |
protocol | Defines the Celery protocol. |
task | Provides the |
Macros
app | A macro for creating a |
Structs
Celery | A |
CeleryBuilder | Used to create a |
Attribute Macros
task | A procedural macro for generating a |