How geofmureithi/apalis works
Project Type & Purpose
• apalis is a Rust workspace providing a modular background-job and message-processing framework. It ships as a collection of crates:
• apalis-core (the in-memory engine & abstractions)
• apalis-cron (cron-job source)
• apalis-redis (Redis backend)
• apalis-sql (SQL backends: SQLite, Postgres, MySQL)
• It is not a single runnable service but a library/toolkit that users embed in their own async apps (Tokio, async-std, etc.) to produce/consume jobs.
File Structure Highlights
• packages/… holds each crate’s source (core, cron, redis, sql).
• src/layers/… inside apalis core exposes built-in Tower middleware (tracing, retry, sentry, prometheus, catch-panic).
• examples/… demonstrates real-world usage: actix-web, axum, REST API, cron pipelines, stepped tasks, different storage backends.
• Top-level Cargo.toml defines the workspace.
Key Architecture Concepts
• Core Service Pipeline: apalis-core defines a Tower Service that:
1. Polls a storage backend for new jobs
2. Passes each job through a stack of middleware layers (tracing, retry, timeout, etc.)
3. Invokes the user’s async handler
4. Reports progress and final status back to the backend
• Pluggable Storage Backends: apalis-redis and apalis-sql implement a Storage trait for persisting and retrieving jobs. apalis-cron acts as a job _source_, piping scheduled entries into another backend.
• Builder Pattern: WorkerBuilder configures name, concurrency, data, middleware toggles, storage backend, then yields a running worker.
• Examples & Integration Points: Users spawn producers (e.g., HTTP route, cron scheduler) that push jobs into the chosen storage. They run one or more worker processes (in the same binary or separate) to consume.