Coder Social home page Coder Social logo

apalis's Introduction

Apalis Build Status

Apalis is a simple, extensible multithreaded background job processing library for Rust.

Features

  • Simple and predictable job handling model.
  • Jobs handlers with a macro free API.
  • Take full advantage of the tower ecosystem of middleware, services, and utilities.
  • Fully Tokio compatible.
  • Optional Web interface to help you manage your jobs.

Apalis job processing is powered by tower::Service which means you have access to the tower middleware.

Apalis has support for

  • Redis
  • SQlite
  • PostgresSQL
  • MySQL
  • Cron Jobs
  • Bring Your Own Job Source eg Twitter streams

Getting Started

To get started, just add to Cargo.toml

[dependencies]
apalis = { version = "0.3", features = ["redis"] }

Usage

use apalis::prelude::*;
use apalis::redis::RedisStorage;
use serde::{Deserialize, Serialize};

#[derive(Debug, Deserialize, Serialize)]
struct Email {
    to: String,
}

async fn email_service(job: Email, _ctx: JobContext) -> Result<JobResult, JobError> {
    Ok(JobResult::Success)
}

#[tokio::main]
async fn main() -> std::io::Result<()> {
    std::env::set_var("RUST_LOG", "debug");
    env_logger::init();
    let redis = std::env::var("REDIS_URL").expect("Missing env variable REDIS_URL");
    let storage = RedisStorage::new(redis).await.unwrap();
    Monitor::new()
        .register_with_count(2, move || {
            WorkerBuilder::new(storage.clone())
                .build_fn(email_service)
        })
        .run()
        .await
}

Then

//This can be in another part of the program or another application
async fn produce_route_jobs(storage: &RedisStorage<Email>) {
    let mut storage = storage.clone();
    storage
        .push(Email {
            to: "[email protected]".to_string(),
        })
        .await
        .unwrap();
}

Web UI

If you are running Apalis Board, you can easily manage your jobs. See a working Rest API here

UI

Feature flags

  • tracing (enabled by default) โ€” Support Tracing ๐Ÿ‘€
  • redis โ€” Include redis storage
  • postgres โ€” Include Postgres storage
  • sqlite โ€” Include SQlite storage
  • mysql โ€” Include MySql storage
  • cron โ€” Include cron job processing
  • sentry โ€” Support for Sentry exception and performance monitoring
  • prometheus โ€” Support Prometheus metrics
  • retry โ€” Support direct retrying jobs
  • timeout โ€” Support timeouts on jobs
  • limit โ€” ๐Ÿ’ช Limit the amount of jobs
  • filter โ€” Support filtering jobs based on a predicate
  • extensions โ€” Add a global extensions to jobs

Storage Comparison

Since we provide a few storage solutions, here is a table comparing them:

Feature Redis Sqlite Postgres Sled Mysql Mongo Cron
Scheduled jobs โœ“ โœ“ โœ“ x โœ“ x โœ“
Retryable jobs โœ“ โœ“ โœ“ x โœ“ x โœ“
Persistence โœ“ โœ“ โœ“ x โœ“ x BYO
Rerun Dead jobs โœ“ โœ“ โœ“ x * x x

Thanks to

  • tower - Tower is a library of modular and reusable components for building robust networking clients and servers.
  • redis-rs - Redis library for rust
  • sqlx - The Rust SQL Toolkit

Roadmap

v 0.4

  • Improve monitoring
  • Improve Apalis Board
  • Add job progress
  • Add more sources *

v 0.3

  • Standardize API (Storage, Worker, Data, Middleware, Context )
  • Introduce SQL
  • Implement layers for Sentry and Tracing.
  • Improve documentation
  • Organized modules and features.
  • Basic Web API Interface
  • Sql Examples
  • Sqlx migrations

v 0.2

  • Redis Example
  • Actix Web Example

Resources

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Authors

See also the list of contributors who participated in this project.

It was formerly actix-redis-jobs and if you want to use the crate name please contact me.

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Acknowledgments

  • Inspiration: The redis part of this project is heavily inspired by Curlyq which is written in GoLang

apalis's People

Contributors

autotaker avatar geofmureithi avatar

Watchers

 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.