Baldur
Baldur is a self-healing reliability layer for Python applications. It puts circuit breaker, retry, and fallback behind a single decorator, so a flaky downstream stops cascading into your service — and it ships the operational surface you need to actually run that in production: health checks, Prometheus and OpenTelemetry metrics, graceful shutdown, and a built-in web console. The core is framework-agnostic, with first-class adapters for Django, FastAPI, Flask, and Celery.
Why Baldur?
- One decorator, whole pipeline.
@baldur.protected("name")composes circuit breaker, retry with backoff, timeout, fallback, and idempotency into one ordered pipeline — instead of hand-wiring three separate libraries and hoping they interact correctly under failure. - Zero-config start, production path built in. Out of the box everything runs on an in-memory backend — no Redis, no env vars, no Docker. When you move to multiple workers, add Redis and the same code shares state across the fleet. Call sites never change.
- Operate it, don't just import it. A built-in web console shows every breaker's live state and gives you runtime on/off controls; health checks tell your load balancer the truth; metrics come standard.
- Framework-native. Django, FastAPI, Flask, and Celery adapters wire the cache, metrics, and lifecycle hooks at startup, so protection works with your framework's idioms rather than around them.
Install
The Python package is baldur (you import baldur); the PyPI distribution is
baldur-framework.
pip install baldur-framework # framework-agnostic core
pip install baldur-framework[django] # Django integration
pip install baldur-framework[fastapi] # FastAPI integration
pip install baldur-framework[flask] # Flask integration
pip install baldur-framework[celery] # Celery task protection
pip install baldur-framework[redis] # Redis-backed shared state
pip install baldur-framework[prometheus] # Prometheus metrics
Quick example
import baldur
@baldur.protected("charge-customer")
def charge(order_id: str) -> dict:
# Wrapped in a circuit breaker by default. With zero configuration this
# runs on an in-memory fallback — no Redis, no env vars, no Docker.
return payment_gateway.charge(order_id)
When the payment gateway starts failing, the breaker opens and your service answers fast instead of stacking up timeouts. Need more than the default? Compose the pipeline declaratively:
@baldur.protected(
"charge-customer",
retry=True, # retry with exponential backoff
timeout=5.0, # per-call time budget
fallback=lambda: {"status": "queued"}, # graceful answer while OPEN
idempotency_key="order_id", # dedupe concurrent duplicates
)
def charge(order_id: str) -> dict:
return payment_gateway.charge(order_id)
Sync and async callables are both supported — the decorator auto-detects coroutine functions.
What's in the box (OSS, Apache-2.0)
| Capability | What it gives you |
|---|---|
| Circuit breaker | Stops cascading failure; bounded half-open probes on recovery |
| Retry with backoff | Exponential backoff with jitter and bounded attempts |
| Fallback & composition | One ordered pipeline for all resilience patterns |
| Idempotency | Concurrent duplicate calls execute the side effect exactly once |
| Bulkhead isolation | Each dependency gets a fixed slice of concurrency, so one slow dependency can't drain every worker |
| Dead-letter queue + replay | A call that fails for good is captured with its context and replayed once the dependency recovers |
| Health checks | Liveness/readiness that reflect real dependency state |
| Graceful shutdown | Drain in-flight work cleanly on restart and deploy |
| Metrics | Prometheus and OpenTelemetry, emitted by default |
| System control | Instant kill switch and dry-run mode for Baldur's automation — no redeploy |
| Web console | Built-in operations console: live breaker state, controls, recovery |
| Precomputed cache | Health/status endpoints answer from a warm cache, so constant probing stays cheap |
Baldur PRO
PRO adds the durable, fleet-level machinery on top of the same API — nothing in the core gets relicensed or replaced. Highlights: DLQ at scale (batch replay from the console, success-rate-driven pacing, a disk-durable outbox, and archive/purge retention), hash-chained audit trail, unified notifications, emergency mode, bulkhead thread-pool isolation, adaptive throttling, canary recovery, governance gates, and a meta-watchdog that watches Baldur itself.
See the full OSS vs PRO capability matrix and pricing.
Documentation
Full documentation lives at https://baldur.sh.
- What is Baldur? — the problem it solves and how
- Getting started: Django · FastAPI · Flask · Celery
- Concept guides — one page per capability, linked throughout this README
- API reference
- Troubleshooting
- Compatibility
Using Baldur with AI assistants
Building with an AI coding assistant (Claude Code, Cursor, Copilot, Codex)? Run
baldur init-ai in your repo to drop an AGENTS.md (read by Cursor, Copilot,
and Codex) plus a CLAUDE.md that imports it for Claude Code — together they
teach the assistant to reach for @baldur.protected("name") instead of
hand-rolling a circuit breaker. See
Using Baldur with AI assistants.
Compatibility
| Component | Minimum | Tested in CI |
|---|---|---|
| Python | 3.11 | 3.11 · 3.12 · 3.13 |
| Django | 4.2 | 4.2 LTS · 5.2 LTS · 6.0 |
| FastAPI | 0.100 | latest ≥ floor (smoke) |
| Flask | 2.3 | latest ≥ floor (smoke) |
| Celery | 5.3 | 5.4 |
| Redis server | — | 7.x |
See Compatibility for the full matrix, the Python × Django test grid, and the version support policy.
License
Baldur is released under the Apache License 2.0 — see LICENSE and NOTICE.
Contributing
Contributions are welcome under the Apache License 2.0. Pull requests are accepted through a sign-off-based DCO flow — see CONTRIBUTING.md for the full model.
- Bugs / feature requests / docs → open an issue or a pull request.
- Security → see SECURITY.md (no public issues for vulnerabilities).
- Usage questions / commercial →
support@baldur.sh.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file baldur_framework-1.3.2.tar.gz.
File metadata
- Download URL: baldur_framework-1.3.2.tar.gz
- Upload date:
- Size: 2.3 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
abe91607a34654e5dc46032a6f7c3cb51c9bcb13f415f72060e33f6a06562c1b
|
|
| MD5 |
29455534e3df1d5e8656ae902ba97ba4
|
|
| BLAKE2b-256 |
8e2b0abb5dcfb4afc64ac28f5238e459ba378ac074b12d494f3c97ebe513402f
|
Provenance
The following attestation bundles were made for baldur_framework-1.3.2.tar.gz:
Publisher:
build-oss.yml on baldurhq/baldur
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
baldur_framework-1.3.2.tar.gz -
Subject digest:
abe91607a34654e5dc46032a6f7c3cb51c9bcb13f415f72060e33f6a06562c1b - Sigstore transparency entry: 2291759872
- Sigstore integration time:
-
Permalink:
baldurhq/baldur@45d3df6a110ac8a904d47ab4f5bbfd3e34da96f7 -
Branch / Tag:
refs/tags/v1.3.2 - Owner: https://github.com/baldurhq
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build-oss.yml@45d3df6a110ac8a904d47ab4f5bbfd3e34da96f7 -
Trigger Event:
push
-
Statement type:
File details
Details for the file baldur_framework-1.3.2-py3-none-any.whl.
File metadata
- Download URL: baldur_framework-1.3.2-py3-none-any.whl
- Upload date:
- Size: 3.0 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
927f6e61721610e4ed217d4ccf97a8a82ba9ae78ea6fc77a998bcc89b8b84a21
|
|
| MD5 |
460df4fce1a73ce56cd39b7190e532d4
|
|
| BLAKE2b-256 |
a2332446d9549bc8410ec9be2b9544dae14020761ba03833cfe2c697578157c2
|
Provenance
The following attestation bundles were made for baldur_framework-1.3.2-py3-none-any.whl:
Publisher:
build-oss.yml on baldurhq/baldur
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
baldur_framework-1.3.2-py3-none-any.whl -
Subject digest:
927f6e61721610e4ed217d4ccf97a8a82ba9ae78ea6fc77a998bcc89b8b84a21 - Sigstore transparency entry: 2291759889
- Sigstore integration time:
-
Permalink:
baldurhq/baldur@45d3df6a110ac8a904d47ab4f5bbfd3e34da96f7 -
Branch / Tag:
refs/tags/v1.3.2 - Owner: https://github.com/baldurhq
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build-oss.yml@45d3df6a110ac8a904d47ab4f5bbfd3e34da96f7 -
Trigger Event:
push
-
Statement type: