[][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 Celery app. It provides the transport for messages that encode tasks.

error

Error types.

protocol

Defines the Celery protocol.

task

Provides the Task trait as well as options for configuring tasks.

Macros

app

A macro for creating a Celery app.

Structs

Celery

A Celery app is used to produce or consume tasks asynchronously. This is the struct that is created with the app macro.

CeleryBuilder

Used to create a Celery app with a custom configuration.

Attribute Macros

task

A procedural macro for generating a Task from a function.