Runtime Backends
The Waxell Runtime uses pluggable backends for different deployment scenarios. This enables the same code to run locally and in production.
Backend Protocols
| Protocol | Default (Runtime) | Production (Infra) |
|---|---|---|
TokenSemaphore | InMemoryTokenSemaphore | RedisTokenSemaphore |
TaskStatusProvider | InMemoryTaskStatusProvider | CeleryTaskStatusProvider |
RuntimeBackend | InMemoryBackend | DjangoRuntimeBackend |
GovernanceHook | (none) | PolicyGovernanceHook |
Local Development
In local development, defaults are used automatically:
from waxell_runtime import RuntimeConfig
# Uses in-memory implementations
config = RuntimeConfig.get()
No Redis, Celery, or Django required for local development.
Production Configuration
Production backends are configured by the waxell-infra Django app:
# settings.py
INSTALLED_APPS = [
...
'waxell_infra', # Automatically configures runtime backends
]
The infra app's ready() hook configures:
RedisTokenSemaphorefor rate limitingCeleryTaskStatusProviderfor async task trackingDjangoRuntimeBackendfor persistencePolicyGovernanceHookfor policy enforcement
Custom Backends
You can implement custom backends by following the protocols:
from waxell_runtime.protocols import TokenSemaphore
class CustomSemaphore(TokenSemaphore):
async def acquire(self, key: str, tokens: int) -> bool:
# Custom implementation
pass
async def release(self, key: str, tokens: int) -> None:
# Custom implementation
pass
Next Steps
- Production Guide - Deploy with production backends
- Architecture Guide - Understand the full system