Skip to main content

Drakkar

Kafka and/or HTTP → subprocess pool → sinks, for Python 3.13+.

Drakkar is an orchestration framework for CPU-heavy stream processing: it consumes messages from Kafka and/or accepts HTTP requests, turns them into invocations of an external binary run in a managed subprocess pool, and delivers the results to any combination of Kafka, PostgreSQL, MongoDB, Redis, HTTP, and files. You write a handler with a few async hooks; the framework owns polling, windowing, backpressure, delivery, offset commits, and observability.

Workers are the Drakkars, executors are the Vikings.

flowchart LR
    K["Kafka<br>source topic"] -- "poll" --> W
    H["HTTP clients"] -- "POST" --> W
    subgraph worker ["Drakkar worker — one pipeline per partition"]
        W["window of<br>messages"] --> A["arrange()<br>your code"]
        A -- "tasks" --> P["subprocess pool<br>runs your binary"]
        P -- "results" --> T["on_task_complete()<br>your code"]
    end
    T -- "payloads" --> S["sinks — any combination<br>Kafka · Postgres · MongoDB · Redis · HTTP · files"]
    S -- "failed delivery" --> DLQ["DLQ topic"]
    S -- "all confirmed" --> CO["commit offsets<br>(watermark)"]

The operator UI: live executor timeline, partition lag, and message tracing

The operator UI every worker serves: the live executor timeline, per-partition lag, and message tracing.

Documentation — full guides for every feature below.

Features

  • Two input sources — Kafka and HTTP, each optional: a worker runs Kafka-only, HTTP-only, or both, behind one handler, one executor pool and one set of sinks
  • Per-partition pipelines with watermark offset tracking — commits happen only after every sink confirmed
  • Sinks — Kafka, PostgreSQL, MongoDB, Redis, HTTP, filesystem; multiple named instances per type
  • Dead letter queue of original messages with replay tooling; each sink declares its failure policy (dlq or skip, a retry budget, depends_on), and on_delivery_error() decides per failure
  • Backpressure in tasks and bytes — new windows wait for room under a worker-wide budget of pending tasks and held stdin, and the Kafka fetch pauses when queues fill, so memory stays bounded regardless of lag
  • Typed messages — Pydantic models as type parameters, auto de/serialization
  • Operator UI — live executor timeline, partition lag, message tracing, and a Message Probe that runs a pasted message through the full pipeline with zero footprint on production state
  • UI customization — handler-defined probe tabs, links/badges/formats on any field, declared dashboard pages — all server-side, no client code
  • Cache (optional) — self.cache key/value store with write-behind SQLite and a cache exchange between workers over HTTP
  • Offload — await self.offload(fn, ...) keeps CPU-bound hook work off the event loop
  • Webapp (optional) — the same handler pipeline exposed as a synchronous HTTP endpoint with auth and rate limits
  • Observability — Prometheus metrics, ECS-compatible structured logging, flight recorder (SQLite event log) and runtime-health and host-pressure monitors
  • Kubernetes-ready — /healthz and /readyz probes, reference manifests, crash/OOM detection on restart
  • Split (optional, off by default) — a handler cuts one very large message into parts that every worker of the group processes; the owner of the message calls aggregate() when every part has a result and commits the offset after it, and a restart of any worker loses no finished part
  • Detach (optional, off by default) — a worker in a degraded mode leaves its Kafka consumer group for a bounded time and joins it again without a restart, asked by the handler or by an operator; a budget in the autodiscover store keeps enough workers of the group attached, and request_stop() stops the worker gracefully with an exit code
  • Agent surface (optional, off by default) — read-only /api/v1/agent routes and the drakkar-agent command explain the worker to an AI agent: the framework knowledge, the effective config with secrets masked, the metrics, the live state and rule-based findings; the handler can add its own notes and rules

The operator UI is drakkar-ui, a versioned SPA the worker fetches at startup and caches on disk — so co-located workers share one download, and the UI ships on its own release cadence.

Quick start

uv init my-processor && cd my-processor
uv add py-drakkar
# handler.py
from pydantic import BaseModel
from drakkar import (
    BaseDrakkarHandler,
    CollectResult,
    ExecutorTask,
    KafkaPayload,
    PostgresPayload,
    make_task_id,
)


class JobInput(BaseModel):
    job_id: str
    command: str


class JobOutput(BaseModel):
    job_id: str
    result: str


class MyHandler(BaseDrakkarHandler[JobInput, JobOutput]):
    async def arrange(self, messages, pending):
        # window of Kafka messages -> subprocess tasks
        return [
            ExecutorTask(
                task_id=make_task_id('job'),
                args=['--cmd', msg.payload.command],
                source_offsets=[msg.offset],
                metadata={'job_id': msg.payload.job_id},
            )
            for msg in messages
        ]

    async def on_task_complete(self, result):
        # subprocess output -> sink payloads
        output = JobOutput(
            job_id=result.task.metadata['job_id'],
            result=result.stdout.strip(),
        )
        return CollectResult(
            kafka=[KafkaPayload(data=output, key=output.job_id.encode())],
            postgres=[PostgresPayload(table='results', data=output)],
        )
# drakkar.yaml
connections:
  kafka:
    main:
      brokers: "localhost:9092"
  postgres:
    main:
      dsn: "postgresql://user:pass@localhost:5432/mydb"

sources:
  kafka:
    enabled: true
    topic: "jobs"
    consumer_group: "my-workers"

executor:
  binary_path: "/usr/local/bin/my-tool"
  max_executors: 8
  task_timeout: 1m

sinks:
  kafka:
    job_results_out:
      topic: "job-results"
  postgres:
    main_db: {}   # uses connections.postgres.main
# main.py
from drakkar import DrakkarApp
from handler import MyHandler

DrakkarApp(handler=MyHandler(), config_path='drakkar.yaml').run()
WORKER_ID=worker-1 python main.py

Every config field can be overridden by environment variables (DK_ prefix, __ for nesting: DK_EXECUTOR__MAX_EXECUTORS=16). Scale horizontally by running more workers in the same consumer group; cooperative-sticky rebalancing spreads partitions without stopping the others.

More hooks are available for aggregation and error handling — on_message_complete (fan-out → fan-in), on_window_complete, arrange_stream with on_group_complete (a message with thousands of tasks, yielded in groups so that memory stays bounded), on_error, @periodic tasks (on every worker, or on one worker of the cluster per slot, by interval or UTC cron), lifecycle hooks. See the handler guide.

Try it

A full docker-compose environment with Kafka, all six sink types, six workers in three clusters, and a load generator lives in integration/:

cd integration
docker compose up --build

Then open http://localhost:8081 for the first worker's UI. See the integration guide.

Security posture

Drakkar is built to run inside a system you own. The operator UI, the /api/v1 JSON and WebSocket surface, and the optional HTTP ingress assume a trusted, private network. Do not expose them to the public internet, to a shared corporate network you do not control, or to a user population wider than the engineers operating the service.

Drakkar does ship security controls — an opt-in UI bearer token with a WebSocket origin check, per-client tokens and rate limits on the HTTP ingress, path containment so the download endpoint can only ever serve recorder databases, secret masking in the config view and the flight recorder, and bounds on request size, header size and connection lifetime. Turn them on. But treat every one of them as defence in depth, not a security perimeter: they exist to reduce blast radius and catch mistakes, not to withstand a determined attacker who already has network access.

A worker has no user model, no roles and no tenancy. Anyone who can reach a port and present the one configured token is an operator of that worker. The real boundary sits where the context is:

  • your network decides who reaches the ports at all — this is the control that matters;
  • your ingress owns TLS, SSO or mTLS, and connection-level limits;
  • your application authorises your end users and validates their input;
  • Drakkar avoids shipping footguns behind that line.

Even inside a private network the UI is an operator tool that shows task output, arguments, redacted environment, cache contents and live event streams — worth a token, or a bastion, if any of that is sensitive.

Full detail, including what Drakkar deliberately does not provide (TLS, CSRF protection, an audit trail, a handler sandbox): Security posture. To report a vulnerability, see SECURITY.md.

Development

just is the dev entrypoint; CI runs the same recipes.

just install     # uv sync with dev + perf extras
just test        # unit tests (hermetic, no network)
just ci          # format check -> lint -> types -> tests + coverage -> strict docs
just docs-serve  # live-reload docs at http://127.0.0.1:8000
just --list      # everything else (integration env, chaos test, DLQ replay, ...)

See docs/development.md and CONTRIBUTING.md.

License

MIT — see LICENSE.

Metadata

Release files for py-drakkar 3.7.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for py-drakkar 3.7.2
File Size Uploaded Provenance Actions
py_drakkar-3.7.2.tar.gz 8.6 MB With provenance Details for py_drakkar-3.7.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for py-drakkar 3.7.2
File Interpreter ABI Platform Actions
py_drakkar-3.7.2-py3-none-any.whl Python 3 none any Details for py_drakkar-3.7.2-py3-none-any.whl

Total release size: 10.4 MB

Release files / py_drakkar-3.7.2.tar.gz

Download URL py_drakkar-3.7.2.tar.gz
Size 8.6 MB
Tags Source
SHA-256 checksum
How to use checksums
25b09fcc50297732ce924dbcd176ca4d7b45b4ca3618b050eca37016030325eb
BLAKE2b-256 checksum
How to use checksums
4abc7402fcc9f7f64890427cbbd5db3fdb12cfb908c7e511f69068a20c01a35c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.

Transparency log

Release files / py_drakkar-3.7.2-py3-none-any.whl

Download URL py_drakkar-3.7.2-py3-none-any.whl
Size 1.7 MB
Tags Python 3
SHA-256 checksum
How to use checksums
9abe197653fea08fafc8d3e10990a23fba96ab9f8d866e28b1b4879619cf0785
BLAKE2b-256 checksum
How to use checksums
512e9a397471fa14f4fbfa976640fa9e1bae6e0480c7a6921515be81bc5e5ab9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.

Transparency log

Security for py-drakkar 3.7.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for py_drakkar-3.7.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

3.7.2 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page