Expand description
A Rust implementation of Celery for producing and consuming asynchronous tasks with a distributed message queue.
§Examples
Define tasks by decorating functions with the task
attribute:
use celery::prelude::*;
#[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 = AMQPBroker { std::env::var("AMQP_ADDR").unwrap() },
tasks = [add],
task_routes = [],
).await?;
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 a worker to consume tasks sent to a queue by a producer, use the
Celery::consume
method:
my_app.consume().await?;
Modules§
- beat
- Celery
Beat
is an app that can automatically produce tasks at scheduled times. - broker
- The broker is an integral part of a
Celery
app. It provides the transport for messages that encode tasks. - error
- All error types used throughout the library.
- prelude
- A “prelude” for users of the
celery
crate. - protocol
- Defines the Celery protocol.
- task
- Provides the
Task
trait as well as options for configuring tasks.
Macros§
Structs§
- Celery
- A
Celery
app is used to produce or consume tasks asynchronously. This is the struct that is created with theapp!
macro. - Celery
Builder - Used to create a
Celery
app with a custom configuration.