Expand description
apalis is a simple, extensible multithreaded background job processing library for rust.
§Core Features
- Simple and predictable functional job handling model with a macro free API.
- Takes full advantage of the
towerecosystem of middleware, services, and utilities. - Anything that implements
Streamcan be used as a job source. - Runtime agnostic with inbuilt support for tokio and async-std.
- Provides high concurrency, and allows for configuration of workers, jobs and thread pool.
An apalis job is powered by a tower Service which means you have access to the tower middleware.
§Example
use apalis::prelude::*;
use serde::{Deserialize, Serialize};
use apalis_redis::{RedisStorage, Config};
#[derive(Debug, Deserialize, Serialize)]
struct Email {
to: String,
}
async fn send_email(job: Email, data: Data<usize>) -> Result<(), Error> {
Ok(())
}
#[tokio::main]
async fn main() {
let redis = std::env::var("REDIS_URL").expect("Missing REDIS_URL env variable");
let conn = apalis_redis::connect(redis).await.unwrap();
let storage = RedisStorage::new(conn);
Monitor::new()
.register({
WorkerBuilder::new(&format!("quick-sand"))
.concurrency(2)
.data(0usize)
.backend(storage.clone())
.build_fn(send_email)
})
.run()
.await
.unwrap();
}§Web UI Available
See this example
§Feature flags
tracing(enabled by default) — Support Tracing 👀sentry— Support for Sentry exception and performance monitoringprometheus— Support Prometheus metricsretry— Support direct retrying jobstimeout— Support timeouts on jobslimit— 💪 Limit the amount of jobsfilter— Support filtering jobs based on a predicatecatch-panic— Captures panics in executions and convert them to errors