Expand description
§kojin
Async distributed task queue for Rust — the equivalent of Celery (Python), BullMQ (Node.js), Sidekiq (Ruby), and Machinery (Go).
This is the main facade crate. It re-exports types from kojin_core,
the #[task] proc-macro from kojin_macros, and optionally the Redis
broker from kojin_redis.
§Features
- Async-first worker runtime built on Tokio
#[kojin::task]proc-macro for defining tasks- Pluggable broker trait (Redis included)
- Composable middleware (tracing, metrics)
- Workflow orchestration: chain, group, chord
- Result backends (memory, Redis, PostgreSQL)
- Graceful shutdown, weighted queues, configurable retries
§Quick Start
use kojin::{KojinBuilder, MemoryBroker};
let broker = MemoryBroker::new();
let worker = KojinBuilder::new(broker)
.concurrency(4)
.queues(vec!["default".into()])
.build();
worker.run().await;Modules§
- backoff
- broker
- canvas
- codec
- context
- error
- memory_
broker - memory_
result_ backend - message
- middleware
- queue_
weight - registry
- result_
backend - shutdown
- signature
- state
- task
- task_id
- worker
Macros§
Structs§
- Json
Codec - JSON codec using serde_json.
- Kojin
Builder - Builder for configuring and running a Kojin worker.
- Memory
Broker - In-memory broker for testing and development.
- Memory
Result Backend - In-memory result backend for development and testing.
- Metrics
Middleware - Simple metrics middleware that tracks task counts.
- Redis
Broker - Redis-backed message broker.
- Redis
Config - Redis broker configuration.
- Redis
Result Backend - Redis-backed result storage.
- Signature
- A type-erased task invocation descriptor.
- Task
Context - Task execution context providing type-safe access to shared data.
- TaskId
- Unique task identifier backed by UUID v7 (time-ordered).
- Task
Message - A task message that flows through the broker.
- Task
Registry - Registry mapping task names to type-erased handlers.
- Tracing
Middleware - Middleware that emits tracing spans for task execution.
- Weighted
Queue - A queue with an associated weight.
- Worker
- The worker loop that dequeues and executes tasks.
- Worker
Config - Worker configuration.
- Workflow
Handle - Handle returned after submitting a workflow.
Enums§
- Backoff
Strategy - Strategy for calculating retry backoff delays.
- Canvas
- A composable workflow description.
- Kojin
Error - Core error type for Kojin.
- Queue
Weight - Queue priority weight for weighted queue selection.
- Task
State - Lifecycle state of a task.
Traits§
- Broker
- Message broker responsible for enqueuing and dequeuing task messages.
- Codec
- Serialization codec for task payloads.
- Middleware
- Middleware hook for task execution pipeline.
- Result
Backend - Backend for storing and retrieving task results.
- Task
- A unit of work that can be enqueued and executed by a worker.
Functions§
- chord
- Create a chord: a group with a callback that fires when all members complete.
Type Aliases§
- Task
Result - Convenience result alias.
Attribute Macros§
- task
- Derive a task struct and
Taskimpl from an async function.