30 releases

0.4.0-rc5 Nov 19, 2020
0.4.0-rc2 Aug 27, 2020
0.3.1 Jul 22, 2020
0.2.5 Mar 24, 2020

#236 in Procedural macros

Download history 57/week @ 2020-08-07 83/week @ 2020-08-14 32/week @ 2020-08-21 84/week @ 2020-08-28 143/week @ 2020-09-04 31/week @ 2020-09-11 30/week @ 2020-09-18 13/week @ 2020-09-25 43/week @ 2020-10-02 10/week @ 2020-10-09 74/week @ 2020-10-16 22/week @ 2020-10-23 152/week @ 2020-10-30 69/week @ 2020-11-06 37/week @ 2020-11-13 108/week @ 2020-11-20

243 downloads per month
Used in celery

Apache-2.0

27KB
711 lines


A Rust implementation of Celery for producing and consuming asyncronous tasks with a distributed message queue.


Build License Crates Docs Help wanted Discord


We welcome contributions from everyone regardless of your experience level with Rust. For complete beginners, see HACKING_QUICKSTART.md.

If you already know the basics of Rust, the Rusty Celery Book is the best place to start. If you're coming from Python you may also be interested to know what's different. And if you've never heard of Celery, the official Celery Project is a great source of tutorials and overviews.

Quick start

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)
}

Create an 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 = [
        "*" => "celery",
    ],
);

Then send tasks to a queue with

my_app.send_task(add::new(1, 2)).await?;

And consume tasks as a worker from a queue with

my_app.consume().await?;

The ./examples directory contains a simple Celery app that is implemented in both Rust (celery_app.rs) and Python (celery_app.py) using an AMQP broker.

If you already have an AMQP broker running you can set the environment variable AMQP_ADDR to your broker's URL (e.g., amqp://localhost:5672//, where the second slash at the end is the name of the default vhost). Otherwise simply run the helper script:

./scripts/brokers/amqp.sh

This will download and run the official RabbitMQ image (RabbitMQ is a popular AMQP broker). Then you can run a Rust worker with:

cargo run --example celery_app consume

And then send tasks to the worker with:

cargo run --example celery_app produce

Alternatively, you can consume or produce tasks from Python by running

python examples/celery_app.py consume

Or

python examples/celery_app.py produce

You'll need to have Python 3 installed, along with the requirements listed in the requirements.txt file.

Road map and current state

✅ = Supported and mostly stable, although there may be a few incomplete features.
⚠️ = Partially implemented and under active development.
🔴 = Not supported yet but on-deck to be implemented soon.

Core

Status Tracking
Protocol ⚠️
Producers
Consumers
Brokers
Backends 🔴
Beat 🔴
Baskets 🔴

Brokers

Status Tracking
AMQP
Redis 🔴

Backends

Status Tracking
RPC 🔴
Redis 🔴

Team

Rusty Celery is an open source community effort. It is also backed by Structurely, a start-up building conversational AI that has been using Python Celery in production since 2017.

Dependencies

~0.4–0.8MB
~21K SLoC