Git Product home page Git Product logo

rollout's Introduction

rollout

Fast feature flags based on Redis.

Build Status Code Climate Test Coverage Dependency Status

Install it

gem install rollout

How it works

Initialize a rollout object. I assign it to a global var.

require 'redis'

$redis   = Redis.new
$rollout = Rollout.new($redis)

Update data specific to a feature:

$rollout.set_feature_data(:chat, description: 'foo', release_date: 'bar', whatever: 'baz')

Check whether a feature is active for a particular user:

$rollout.active?(:chat, User.first) # => true/false

Check whether a feature is active globally:

$rollout.active?(:chat)

You can activate features using a number of different mechanisms.

Groups

Rollout ships with one group by default: "all", which does exactly what it sounds like.

You can activate the all group for the chat feature like this:

$rollout.activate_group(:chat, :all)

You might also want to define your own groups. We have one for our caretakers:

$rollout.define_group(:caretakers) do |user|
  user.caretaker?
end

You can activate multiple groups per feature.

Deactivate groups like this:

$rollout.deactivate_group(:chat, :all)

Specific Users

You might want to let a specific user into a beta test or something. If that user isn't part of an existing group, you can let them in specifically:

$rollout.activate_user(:chat, @user)

Deactivate them like this:

$rollout.deactivate_user(:chat, @user)

User Percentages

If you're rolling out a new feature, you might want to test the waters by slowly enabling it for a percentage of your users.

$rollout.activate_percentage(:chat, 20)

The algorithm for determining which users get let in is this:

CRC32(user.id) % 100_000 < percentage * 1_000

So, for 20%, users 0, 1, 10, 11, 20, 21, etc would be allowed in. Those users would remain in as the percentage increases.

Deactivate all percentages like this:

$rollout.deactivate_percentage(:chat)

Note that activating a feature for 100% of users will also make it active "globally". That is when calling Rollout#active? without a user object.

In some cases you might want to have a feature activated for a random set of users. It can come specially handy when using Rollout for split tests.

$rollout = Rollout.new($redis, randomize_percentage: true)

When on randomize_percentage will make sure that 50% of users for feature A are selected independently from users for feature B.

Global actions

While groups can come in handy, the actual global setter for a feature does not require a group to be passed.

$rollout.activate(:chat)

In that case you can check the global availability of a feature using the following

$rollout.active?(:chat)

And if something is wrong you can set a feature off for everybody using

Deactivate everybody at once:

$rollout.deactivate(:chat)

For many of our features, we keep track of error rates using redis, and deactivate them automatically when a threshold is reached to prevent service failures from cascading. See https://github.com/jamesgolick/degrade for the failure detection code.

Namespacing

Rollout separates its keys from other keys in the data store using the "feature" keyspace.

If you're using redis, you can namespace keys further to support multiple environments by using the redis-namespace gem.

$ns = Redis::Namespace.new(Rails.env, redis: $redis)
$rollout = Rollout.new($ns)
$rollout.activate_group(:chat, :all)

This example would use the "development:feature:chat:groups" key.

Frontend / UI

Implementations in other languages

Contributors

Copyright

Copyright (c) 2010-InfinityAndBeyond BitLove, Inc. See LICENSE for details.

rollout's People

Contributors

jamesgolick avatar reneklacan avatar ericr avatar eric avatar raychatter avatar johnbaku avatar pusewicz avatar jastkand avatar michaeldwan avatar snags88 avatar shaneog avatar ainsleyc avatar ayrton avatar burin avatar chrisledet avatar clowder avatar eoconnell avatar maclover7 avatar justincampbell avatar kwbock avatar mcasper avatar thedrow avatar peeja avatar readmecritic avatar richardfullmer avatar dlackty avatar tallama avatar tejanium avatar jd-erreape avatar juandebravo avatar

Watchers

James Cloos avatar  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.