GithubHelp home page GithubHelp logo

pyrollout's Introduction

pyrollout

Python feature flagging

Build Status

Inspired by the rollout Ruby gem by James Golick and a Python port of it called proclaim by [Curt Micol](Curt Micol) which I found after reading Using Feature Flags to Ship Changes with Confidence by Mathias Meyer.

Both of these use redis, and I don't like that requirement. I seek to support multiple storage/persistence mechanisms.

Usage

To initialize pyrollout with the default in-memory feature & user storage:

import pyrollout
rollout = pyrollout.Rollout()

Now add features:

from pyrollout.feature import Feature
# Open to all by using the special group 'ALL'
rollout.add_feature(Feature('feature_for_all', groups=['ALL']))
# Open to select groups
rollout.add_feature(Feature('feature_for_groups', groups=['vip', 'early_adopter]))
# Open to specific user(s), by user ID
rollout.add_feature(Feature('feature_for_users', users=[123, 456, 789]))
# Open to 20% of users, calculated via user ID
rollout.add_feature(Feature('20pct', percentage=20))

Check access to features:

def untested_feature(user):
    # Because this feature was not defined, access will always be denied (by default)
    if not rollout.can(user, 'use_untested_feature'):
        return None
    else:
        do_cool_things()

class FooHandler(BaseHandler):
    def get(self):
        # self.user is a user object in a format pyrollout understands
        if not rollout.can(self.user, 'feature_for_users'):
            self.abort(403)
        else:
            do_foo()

Some feature ideas

  • Flag on user property
  • Flag on lambda passed the user object
  • Use file
  • Use memcache, e.g. in Google App Engine
  • Use some other persistent database

pyrollout's People

Contributors

brechin avatar daveisadork 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.