flaggo-python
v1.1.0
Published
Python SDK for Flaggo - A minimalist, zero-config feature flag library.
Downloads
21
Readme
🐍 flaggo-python
Python SDK for Flaggo - The minimalist, zero-config feature flag library.
📦 Installation
pip install flaggo-python🚀 Quick Start
Standard Synchronous Usage
from flaggo import Flaggo
# Load flags from a URL or local file
flags = Flaggo.load(
source="https://config.example.com/flags.json",
cache_ttl=600,
context={"userId": "user-123"}
)
if flags.is_enabled("new-feature"):
print("Feature is active!")Asynchronous Usage (FastAPI, etc.)
import asyncio
from flaggo import Flaggo
async def main():
flags = await Flaggo.async_load("flags.json")
if flags.is_enabled("beta-test"):
# ...
pass
asyncio.run(main())✨ Advanced Features
Custom Targeting Rules
Beyond userId, you can use custom rules based on any context field.
# context = {"userId": "123", "role": "admin", "plan": "enterprise"}
if flags.is_enabled("admin-panel", {"role": "admin"}):
# This rule is evaluated before the rollout percentage
passVariants (A/B Testing)
variant = flags.get_variant("header-style")
if variant == "modern":
render_modern_header()
else:
render_classic_header()Thread-Safety & Performance
- Optimized Hashing: Native Python FNV-1a implementation for high performance.
- Thread-safe Cache: Securely use Flaggo in multi-threaded environments (Gunicorn, etc.).
- Automatic Fallback: If the configuration fails to load, Flaggo defaults to a safe empty configuration instead of crashing.
📖 Documentation
For the full specification and other SDKs (JS, Go, Rust), visit the main repository.
📄 License
MIT
