Skip to main content

Simple feature-flag module with per-tenant overrides and a consumer API for simple_module

Project description

simple_module_feature_flags

Feature flags for simple_module apps. Global flags with per-tenant overrides, a tiny consumer API, and no external service to run.

Install

pip install simple_module_feature_flags

What it provides

  • Flag and TenantFlagOverride SQLModel tables.
  • is_enabled("flag.name", tenant_id=...) consumer API.
  • Admin UI at /feature-flags/admin — toggle flags, add tenant overrides.
  • Cache layer so checking a flag on every request is cheap.

Usage

Gate a route:

from feature_flags import is_enabled   # type: ignore[import-not-found]
from fastapi import APIRouter, Depends, HTTPException

router = APIRouter()


@router.get("/new-feature")
async def new_feature(tenant_id: int = Depends(current_tenant_id)):
    if not await is_enabled("orders.new_pricing_engine", tenant_id=tenant_id):
        raise HTTPException(404)
    return {"rolled_out": True}

Seed a flag in a migration or admin UI:

# via migration
Flag(name="orders.new_pricing_engine", enabled=False)

Tenant override:

TenantFlagOverride(tenant_id=7, flag_name="orders.new_pricing_engine", enabled=True)

Depends on

  • simple_module_core, simple_module_db, simple_module_hosting

License

MIT — see LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

simple_module_feature_flags-0.0.3.tar.gz (13.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

simple_module_feature_flags-0.0.3-py3-none-any.whl (15.8 kB view details)

Uploaded Python 3

File details

Details for the file simple_module_feature_flags-0.0.3.tar.gz.

File metadata

File hashes

Hashes for simple_module_feature_flags-0.0.3.tar.gz
Algorithm Hash digest
SHA256 ae053e44a3cba9b87b599a7ea6104e781431d6e387c4ba0b92ed57fcd9c545c1
MD5 fa2548f488c8a0031a27ff39b9a57b85
BLAKE2b-256 4486e6ef757e09a3c3a35403516dae3faa7fcbe42de6d9c79af7ca65f23fa2f3

See more details on using hashes here.

Provenance

The following attestation bundles were made for simple_module_feature_flags-0.0.3.tar.gz:

Publisher: release.yml on antosubash/simple_module_python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file simple_module_feature_flags-0.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for simple_module_feature_flags-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 691fad8f79c964f83a5529274f8baf89728e5bddd1cd8582bc5bdc899fc01f7f
MD5 850d55872cefa51c0ce766435b2e0418
BLAKE2b-256 8cee1c5e101d89b851225d572d0453c0ab69b82a6352d7b1115b118a8c845db2

See more details on using hashes here.

Provenance

The following attestation bundles were made for simple_module_feature_flags-0.0.3-py3-none-any.whl:

Publisher: release.yml on antosubash/simple_module_python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page