Giter VIP home page Giter VIP logo

feature-toggles's Introduction

Feature Toggles

This repo provides functionality for feature toggles in python code.

What does this package do?

  1. It allows to access the configured toggles like toggles.feature1
  2. It logs all uses of the toggle
  3. 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 toggle
  • name: a human readable name for the toggle
  • jira: 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 toggle
  • max_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

feature-toggles's People

Contributors

datteam avatar ericvanderveldevwt avatar erikvwt avatar markbruisten avatar uelei avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.