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
- Flags are declared via the framework
register_feature_flagshook (FeatureFlagDefinition(name, default_enabled=...)); the module persists only overrides in thefeature_flags_overrideSQLModel table (scoped byscope/scope_id). FeatureFlagRegistry.is_enabled("flag.name", tenant_id=...)consumer API (resolution order: tenant override > system override > declared default).- Admin UI at
/feature_flags— toggle flags, add per-scope overrides. - The registry is an in-memory cache hydrated from the DB so checking a flag on every request is cheap.
Usage
Declare a flag in your module:
from simple_module_core.feature_flags import FeatureFlagDefinition, FeatureFlagRegistry
class OrdersModule(ModuleBase):
def register_feature_flags(self, registry: FeatureFlagRegistry) -> None:
registry.add(FeatureFlagDefinition(name="orders.new_pricing_engine", default_enabled=False))
Gate a route using the registry dependency:
from fastapi import APIRouter, HTTPException
from feature_flags.deps import FeatureFlagRegistryDep # type: ignore[import-not-found]
router = APIRouter()
@router.get("/new-feature")
async def new_feature(flags: FeatureFlagRegistryDep):
if not flags.is_enabled("orders.new_pricing_engine"):
raise HTTPException(404)
return {"rolled_out": True}
Overrides (system or per-tenant) are managed through the admin UI at /feature_flags.
Depends on
simple_module_core,simple_module_db,simple_module_hosting
License
MIT — see LICENSE.
Project details
Release history Release notifications | RSS feed
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 simple_module_feature_flags-0.0.20.tar.gz.
File metadata
- Download URL: simple_module_feature_flags-0.0.20.tar.gz
- Upload date:
- Size: 15.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d6c845afa0ca90fa1edb7cf67aa112dd1b01f41e995c46222a4a1f90826d9acd
|
|
| MD5 |
d5e2add6c9b256958ed6f5def9e80cc2
|
|
| BLAKE2b-256 |
f1c8962b1d23a8754f9e29891ff157cce160f24bbcf109b24a66cffec99b4f55
|
Provenance
The following attestation bundles were made for simple_module_feature_flags-0.0.20.tar.gz:
Publisher:
release.yml on antosubash/simple_module_python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
simple_module_feature_flags-0.0.20.tar.gz -
Subject digest:
d6c845afa0ca90fa1edb7cf67aa112dd1b01f41e995c46222a4a1f90826d9acd - Sigstore transparency entry: 1908525329
- Sigstore integration time:
-
Permalink:
antosubash/simple_module_python@fef09599c696d641134ff17e3f2bd6bc5d5a14be -
Branch / Tag:
refs/heads/main - Owner: https://github.com/antosubash
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@fef09599c696d641134ff17e3f2bd6bc5d5a14be -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file simple_module_feature_flags-0.0.20-py3-none-any.whl.
File metadata
- Download URL: simple_module_feature_flags-0.0.20-py3-none-any.whl
- Upload date:
- Size: 16.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d69139889689ed57b6b3ad6104f843adfb5e2d8449e8681e088140633f31c676
|
|
| MD5 |
c2cc6314fd42fabdf2c10a9c0eb7c814
|
|
| BLAKE2b-256 |
6aa29d43705ea6b175364e236be369ff817eeebf837f7bda98fa0bf98af04d86
|
Provenance
The following attestation bundles were made for simple_module_feature_flags-0.0.20-py3-none-any.whl:
Publisher:
release.yml on antosubash/simple_module_python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
simple_module_feature_flags-0.0.20-py3-none-any.whl -
Subject digest:
d69139889689ed57b6b3ad6104f843adfb5e2d8449e8681e088140633f31c676 - Sigstore transparency entry: 1908525443
- Sigstore integration time:
-
Permalink:
antosubash/simple_module_python@fef09599c696d641134ff17e3f2bd6bc5d5a14be -
Branch / Tag:
refs/heads/main - Owner: https://github.com/antosubash
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@fef09599c696d641134ff17e3f2bd6bc5d5a14be -
Trigger Event:
workflow_dispatch
-
Statement type: