Coder Social home page Coder Social logo

jadegeek / rusty-celery Goto Github PK

View Code? Open in Web Editor NEW

This project forked from rusty-celery/rusty-celery

0.0 1.0 0.0 412 KB

Rust implementation of Celery for producing and consuming background tasks

Home Page: https://rusty-celery.github.io

License: Apache License 2.0

Makefile 0.78% Rust 99.16% Shell 0.05%

rusty-celery's Introduction


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?;

Examples

The ./examples directory contains:

  • a simple Celery app implemented in Rust using an AMQP broker (celery_app.rs);
  • the same Celery app implemented in Python (celery_app.py);
  • and a Beat app implemented in Rust (beat_app.rs).

Prerequisites

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

Run the examples

Run Rust Celery app

You can consume tasks with:

cargo run --example celery_app consume

And you can produce tasks with:

cargo run --example celery_app produce

Run Python Celery app

Similarly, 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.

Run Rust Beat app

You can start the Rust beat with:

cargo run --example beat_app

And then you can consume tasks from Rust or Python as explained above.

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
Beat
Backends 🔴
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.

rusty-celery's People

Contributors

epwalsh avatar dependabot-preview[bot] avatar crash-g avatar javednissar avatar tjhall13 avatar peter-formlogic avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.