Python SDK for FOFF Feature Config service
Project description
FOFF Feature Config Python SDK
Python SDK for the FOFF Feature Config service. Provides both sync and async clients with built-in caching and background polling.
Installation
pip install foff
Quick Start
Sync Client
from foff import Client, Config
config = Config(
api_key="your-api-key",
base_url="https://foff.twospoon.ai/live",
scope="production",
polling_interval=30, # refresh configs every 30 seconds (0 to disable)
)
with Client(config) as client:
value = client.get_feature_config("dark_mode", ["prod", "us-east", "acme"])
print(value) # e.g. {"enabled": True, "beta": True}
Async Client
import asyncio
from foff import AsyncClient, Config
config = Config(
api_key="your-api-key",
base_url="https://foff.twospoon.ai/live",
scope="production",
polling_interval=30,
)
async def main():
async with AsyncClient(config) as client:
value = client.get_feature_config("dark_mode", ["prod", "us-east", "acme"])
print(value)
asyncio.run(main())
Configuration
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
api_key |
str |
Yes | API key for authentication | |
base_url |
str |
Yes | Base URL of the FOFF service | |
scope |
str |
Yes | Scope identifier for your configs | |
polling_interval |
int |
No | 30 |
Polling interval in seconds (0 disables polling) |
Feature Lookup
value = client.get_feature_config(feature_name, ordered_hierarchy)
feature_name— the name of the feature flagordered_hierarchy— a list of hierarchy levels from broadest to most specific
The SDK resolves configs from most specific to least specific. Given ["prod", "us-east", "acme"], it checks:
prod#us-east#acmeprod#us-eastproddefault
Returns the first match, or None if the feature doesn't exist.
Client Lifecycle
Sync
The Client constructor performs a blocking initial fetch. If the fetch fails, an exception is raised and no resources are leaked.
# Context manager (recommended)
with Client(config) as client:
...
# Manual
client = Client(config)
try:
...
finally:
client.close()
Async
The AsyncClient constructor is lightweight — no network calls. Call start() or use async with to initialize.
# Context manager (recommended)
async with AsyncClient(config) as client:
...
# Manual
client = AsyncClient(config)
await client.start()
try:
...
finally:
await client.close()
Background Polling
When polling_interval > 0, the client refreshes configs in the background. Polling errors are silently ignored — the client continues serving the last successfully fetched configs.
Call close() (or exit the context manager) to stop polling and release resources.
Development
pip install -e ".[dev]"
pytest tests/
Contributing
License
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 foff-0.1.0.tar.gz.
File metadata
- Download URL: foff-0.1.0.tar.gz
- Upload date:
- Size: 11.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0578e5e7d1780100c2e34047b3bdfd6eee240bf987d9be9ea5a370323dff5d4c
|
|
| MD5 |
c9c10be935f81885fc12e412106275df
|
|
| BLAKE2b-256 |
8c9d7feee14a09f5ae59655b3b925899595545b212e56a99941e0ffa247d7019
|
Provenance
The following attestation bundles were made for foff-0.1.0.tar.gz:
Publisher:
release.yml on twospoon/foff-feature-config-python-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
foff-0.1.0.tar.gz -
Subject digest:
0578e5e7d1780100c2e34047b3bdfd6eee240bf987d9be9ea5a370323dff5d4c - Sigstore transparency entry: 1328193152
- Sigstore integration time:
-
Permalink:
twospoon/foff-feature-config-python-sdk@39ba588a123d6c38b2783107d41748acb6726b9c -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/twospoon
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@39ba588a123d6c38b2783107d41748acb6726b9c -
Trigger Event:
release
-
Statement type:
File details
Details for the file foff-0.1.0-py3-none-any.whl.
File metadata
- Download URL: foff-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.2 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 |
fd4087973c2c9cb97494f53c4e503d8b40388ce864f153b53c0bfb0630a591d4
|
|
| MD5 |
d687d7a3c2c41cfa60a30bb9fca435cc
|
|
| BLAKE2b-256 |
21d2422b1485512c782936ed6a47890e4009e92a46b94b7efb546a0971231ee6
|
Provenance
The following attestation bundles were made for foff-0.1.0-py3-none-any.whl:
Publisher:
release.yml on twospoon/foff-feature-config-python-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
foff-0.1.0-py3-none-any.whl -
Subject digest:
fd4087973c2c9cb97494f53c4e503d8b40388ce864f153b53c0bfb0630a591d4 - Sigstore transparency entry: 1328193168
- Sigstore integration time:
-
Permalink:
twospoon/foff-feature-config-python-sdk@39ba588a123d6c38b2783107d41748acb6726b9c -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/twospoon
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@39ba588a123d6c38b2783107d41748acb6726b9c -
Trigger Event:
release
-
Statement type: