A package to configure feature flags and log the use of the toggles
Project description
Feature Toggles
This repo provides functionality for feature toggles in python code.
What does this package do?
- It allows to access the configured toggles like
toggles.feature1
- It logs all uses of the toggle
- It logs a warning when toggles have exceeded their maximum lifetime
How to use
Configure the toggles
The toggles are configured in yaml.
feature1:
value: true
name: New Thing Toggler
description: This toggles the new thing on
jira: DAN-123
creation_date: 2020-10-12
max_lifetime: 14
Required fields:
value
: a boolean setting the value of the togglename
: a human readable name for the togglejira
: the JIRA ticket that this toggle is linked to.creation_date
: the date this toggle is introduced.
Optional fields:
description
: A description of the purpose and use of the togglemax_lifetime
: The number of days this toggle is supposed to be in the code. A warning will be logged when this lifetime is exceeded. The default is 14 days.
Declare the toggles
To use the configured toggles they need to be declared in the code like this:
from featuretoggles import TogglesList
class ReleaseToggles(TogglesList):
feature1: bool
feature2: bool
toggles = ReleaseToggles('toggles.yaml')
The toggle can be used to gate particular bits of code like this:
if toggles.feature1:
print("Feature One Activated")
else:
print("Feature One Deactivated")
Demo
See demo for a working example
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
featuretoggles-1.0.1.tar.gz
(3.2 kB
view hashes)
Built Distribution
Close
Hashes for featuretoggles-1.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e12d9b2ddf007c5f7beba7ab64f145ebf8bbb802584e831de75108c3e9c80092 |
|
MD5 | 57aa9d49b5a4dfaf7f32bda88a90116f |
|
BLAKE2b-256 | 42ef852ed181431251984a7da6f275bd92d1454dd4e6e69f500228e4c5cefe35 |