[−][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:
#[task] fn add(x: i32, y: i32) -> i32 { x + y }
Then create a Celery
app with the celery_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 = [], );
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?;
Modules
protocol | Defines the Celery protocol. |
Macros
celery_app | A macro for creating a |
Structs
AMQPBroker | An AMQP broker. |
AMQPBrokerBuilder | Builds an AMQP broker with a custom configuration. |
Celery | A |
CeleryBuilder | Used to create a |
Error | Any error that can occur while using |
Rule | A rule for routing tasks to a queue based on a glob pattern. |
TaskContext | Additional context sent to the |
TaskOptions | General configuration options pertaining to a task. |
TaskSendOptions | Options for sending a task. Used to override the defaults. |
TaskSendOptionsBuilder | Used to create custom |
Enums
ErrorKind | Error kinds that can occur while using |
Traits
Broker | A message |
BrokerBuilder | A |
ResultExt | Extension methods for |
Task | A |
Attribute Macros
task | A procedural macro for generating a |