Feature Flags Manager
Project description
Toggler
Toggler allows to set up feature toggles (flags) on a YAML file and validate whether specific flag is ON or OFF on specific environment.
How to Use
Configure Feature Toggles
Feature toggles are configured in yaml
file:
---
prod:
feature2:
active: true
stage:
feature1:
active: true
ref: r123
deadline: 2022-01-01
feature2:
active: true
feature3:
active: false
Structure:
- modes (e.g prod, stage), defines features defined on specific mode.
- features (e.g feature1, feature2) are feature names used to identify which
feature is used or not:
- active: whether feature is enabled or not. If feature is not defined on specific mode, it is implicitly treated as disabled. This is the only required field.
- ref: reference to feature or ticket (for convenience).
- deadline: if set, will check if feature flag has been for too long and logs a warning if its passed a deadline.
Define mode and config file path
You can either explicitly initialize Toggler
with its optional arguments, mode
and path
(or stream
) or you can use environment variables TOGGLER_MODE
and TOGGLER_CFG
.
For example:
TOGGLER_MODE=prod TOGGLER_CFG=/path/to/tog.yml my-app
Initialize Toggler
and check features activity
from toggler.toggler import Toggler
tog = Toggler() # expecting specified env variables
if tog.is_active("feature1"):
# feature1 logic
...
else:
# old logic
...
Using toggler in tests
You can force toggle feature to make it easier to test.
from toggler.env import toggle_feature
def test_feature1_on():
with toggle_feature("feature1", True): # Force enable
# test if feature1 logic works as expected
...
def test_feature1_off():
with toggle_feature("feature1", False): # Force disable
# test if logic without feature1 works as expected
...
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
toggler-0.2.0.tar.gz
(9.5 kB
view details)
Built Distribution
File details
Details for the file toggler-0.2.0.tar.gz
.
File metadata
- Download URL: toggler-0.2.0.tar.gz
- Upload date:
- Size: 9.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bda2634aa082a108b2241c81d55b0fe8992c3ab84f9f632ca270d53fe622eef9 |
|
MD5 | 79e78b755b0aacfa40762079ec17cc30 |
|
BLAKE2b-256 | a99b3f96c382cfa2d3efad56938e6d3c4b9b38f10b5d8f23b50b80cef98d2a22 |
File details
Details for the file toggler-0.2.0-py2.py3-none-any.whl
.
File metadata
- Download URL: toggler-0.2.0-py2.py3-none-any.whl
- Upload date:
- Size: 8.4 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f5c2382229cc5c64ca99630088f3be608fc8e6f94b74831a8400ffb4545db8f9 |
|
MD5 | d3bb65d7e64422bad820f21e02e0ddde |
|
BLAKE2b-256 | 5438156aae3c5f05e005ce6f4dddd3de5e4c0d774cd1e2317199f2671d006ea4 |