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:

---
feature1:
  modes: [prod, stage]
  date: 2023-01-01
  days_to_expire: 10
  ref: r123
feature2:
  modes: [stage]
  date: 2023-01-01
feature3:
  modes: [other]
  date: 2023-01-01

Structure:

  • modes (e.g prod, stage), defines features enabled 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).
    • date: when feature flag was added.
    • days_to_expire: how many days feature flag is to stay. Warning logs will be written after 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.services.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.1.tar.gz (9.5 kB view details)

Uploaded Source

Built Distribution

toggler-0.2.1-py2.py3-none-any.whl (8.5 kB view details)

Uploaded Python 2 Python 3

File details

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

File metadata

  • Download URL: toggler-0.2.1.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

Hashes for toggler-0.2.1.tar.gz
Algorithm Hash digest
SHA256 c449bd67e9a50e521cc805fccc17aafba179b60c967f89d83e846fe7b641fb76
MD5 9a379e49893ec6ef1ae17479b91a6648
BLAKE2b-256 3af8aaab1823c563e4359ee05c668bf7332aeb0299377ba7d2b1f8421a2efeb1

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for toggler-0.2.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 154ad26181cc544c0ed51bb614800b7347a27a326448c6fa2b9ffd294d9e17d4
MD5 4b7caf5f78474e578912e693694a0e1e
BLAKE2b-256 34de81698a405e647acd0a8d320d6d5856fa1ee9c7580df74d69eb44a7596fd6

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