Kathikon

Kathikon (Greek: καθήκον — duty, obligation) is a BEAM-native durable job queue and task execution platform for Elixir.

Jobs are treated as durable obligations that must eventually be fulfilled: completed, retried, cancelled, or discarded — but never silently lost.

Kathikon uses Mnesia as its coordination store and OTP as its execution substrate. No PostgreSQL, Redis, RabbitMQ, or external brokers are required.

Status

v0.1.0 — Phase 1: Durable Job Queue

Installation

def deps do
[
{:kathikon, "~> 0.1.0"}
]
end

Quick start

Define a worker:

defmodule MyApp.EmailWorker do
use Kathikon.Worker
@impl true
def perform(%Kathikon.Job{args: %{"email" => email}}) do
MyApp.Mailer.deliver(email)
:ok
end
end

Configure queues:

# config/config.exs
config :kathikon,
queues: [
default: [concurrency: 10],
emails: [concurrency: 5]
]

Enqueue jobs:

{:ok, job} = Kathikon.insert(MyApp.EmailWorker, %{"email" => "user@example.com"})
{:ok, job} =
Kathikon.insert(MyApp.EmailWorker, %{"email" => "user@example.com"},
queue: :emails,
priority: 5,
schedule_in: 60,
max_attempts: 10
)

Cancel a pending job:

{:ok, job} = Kathikon.cancel(job_id)

Architecture

Kathikon.Supervisor
├── Registry
├── Kathikon.Queue (DynamicSupervisor)
│ └── Kathikon.Dispatcher (one per queue)
├── Kathikon.Scheduler
└── Kathikon.Pruner
ModuleRole
Kathikon.JobJob struct and state machine
Kathikon.WorkerWorker behaviour (perform/1)
Kathikon.StorageStorage facade over Kathikon.Backend.Storage
Kathikon.DispatcherClaims and executes jobs per queue
Kathikon.SchedulerPromotes scheduled jobs to available
Kathikon.PrunerEnforces retention on terminal jobs
Kathikon.Backend.StorageStorage behaviour (default: …Mnesia)
Kathikon.Telemetry[:kathikon, ...] telemetry events

Job states

scheduledavailableexecutingcompleted
↘ ↘ retryable...
cancelled discarded

Telemetry

Kathikon emits standard telemetry events. See Telemetry guide for the full list. Highlights:

Attach the default logger in development:

Kathikon.Telemetry.attach_default_logger()

Configuration

KeyDefaultDescription
:queues[default: [concurrency: 10]]Queue names and concurrency
:poll_interval200Dispatcher poll interval (ms)
:scheduler_interval1000Scheduler tick interval (ms)
:prune_interval60000Pruner tick interval (ms)
:retention_period7 daysHow long to keep terminal jobs (ms)
:max_attempts20Default retry limit
:mnesia_copies:autoMnesia storage: :ram, :disc, or :auto (ram on nonode@nohost and Livebook nodes)

Roadmap

PhaseFocus
1Durable job queue (current)
2Distributed coordination, leases, lifeline
3Cron, uniqueness, dynamic queues
4Rate limits, pause/resume
5Batches
6Observability APIs
7Workflows and DAGs
8Optional LiveView dashboard

Documentation

Generate HTML docs with ExDoc:

mix docs
open doc/index.html

License

MIT. See LICENSE.