Skip to main content

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.1.2.tar.gz (8.4 kB view details)

Uploaded Source

Built Distribution

toggler-0.1.2-py2.py3-none-any.whl (6.5 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file toggler-0.1.2.tar.gz.

File metadata

  • Download URL: toggler-0.1.2.tar.gz
  • Upload date:
  • Size: 8.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.2

File hashes

Hashes for toggler-0.1.2.tar.gz
Algorithm Hash digest
SHA256 4af6b85fc0d8df0137a6faccd21ddc00936c0d6b539b9728bfe9c30c5334d4e7
MD5 80e519af68b11689c793eee9e686657d
BLAKE2b-256 20e03ca2f4ce300582ed71b758cebead92d609738878358a767945c5c82e1120

See more details on using hashes here.

File details

Details for the file toggler-0.1.2-py2.py3-none-any.whl.

File metadata

  • Download URL: toggler-0.1.2-py2.py3-none-any.whl
  • Upload date:
  • Size: 6.5 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.2

File hashes

Hashes for toggler-0.1.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 38d146de3014c714b15266d595729e3bf53dfd4e47676a56e947db100b3896da
MD5 deff8253ca2aff16888d66e9c5eda462
BLAKE2b-256 0b439c9f5fdcfd6d4b93a15b4535af3e41dc25abeedd053b2f08b200eae66234

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page