Skip to content

JacobCoffee/litestar-flags

Repository files navigation

litestar-flags

Production-ready feature flags for Litestar applications.

PyPI version Python versions License

Installation

uv add litestar-flags

# With extras
uv add litestar-flags[redis]        # Redis backend
uv add litestar-flags[database]     # SQLAlchemy backend
uv add litestar-flags[workflows]    # Approval workflows
uv add litestar-flags[openfeature]  # OpenFeature SDK provider
uv add litestar-flags[prometheus]   # Prometheus metrics
uv add litestar-flags[observability] # OpenTelemetry + structlog
uv add litestar-flags[all]          # Everything

Quick Start

from litestar import Litestar, get
from litestar_flags import FeatureFlagsPlugin, FeatureFlagsConfig, FeatureFlagClient

config = FeatureFlagsConfig()
plugin = FeatureFlagsPlugin(config=config)

@get("/")
async def index(feature_flags: FeatureFlagClient) -> dict:
    if await feature_flags.is_enabled("new_checkout"):
        return {"flow": "new"}
    return {"flow": "legacy"}

app = Litestar(plugins=[plugin])

Features

  • Multiple backends - Memory, Redis, and SQLAlchemy storage
  • Percentage rollouts - Gradual releases with consistent hashing
  • User targeting - Rules based on user attributes
  • Segment-based targeting - Reusable user groups for complex targeting
  • A/B testing - Weighted variants for experiments
  • Time-based rules - Scheduled launches and maintenance windows
  • Multi-environment - Environment inheritance, promotion, and per-env configs
  • Admin API - REST endpoints for flag management with RBAC and audit logging
  • Analytics - Evaluation tracking, metrics, and Prometheus export
  • OpenFeature support - Vendor-agnostic evaluation via OpenFeature SDK
  • Approval workflows - Human-in-the-loop governance for enterprise use

Documentation

Full docs at flags.litestar.scriptr.dev.

Development

git clone https://github.com/JacobCoffee/litestar-flags.git
cd litestar-flags
uv sync --all-extras
uv run pytest

License

MIT

About

Questionably-ready feature flags for Litestar

Topics

Resources

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors