Giter VIP home page Giter VIP logo

rollout's Introduction

rollout

Conditionally roll out features with redis.

Install it

gem install rollout

How it works

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

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

Check whether a feature is active for a particular user:

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

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 letting in a percentage of your users.

$rollout.activate_percentage(:chat, 20)

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

user.id % 10 < percentage / 10

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)

Feature is broken

Deactivate everybody at once:

$rollout.deactivate_all

For some of our less stable features, we are actually measuring the error rate using redis, and deactivating them automatically when it raises above a certain threshold. It’s pretty cool. See github.com/jamesgolick/degrade for the failure detection code.

Namespacing

Rollout separates its keys from other keys on the Redis server using the “feature” keyspace.

You can namespace keys further to support multiple environments by using the github.com/defunkt/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.

Implementations in other languages

Note on Patches/Pull Requests

  • Fork the project.

  • Make your feature addition or bug fix.

  • Add tests for it. This is important so I don’t break it in a future version unintentionally.

  • Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)

  • Send me a pull request. Bonus points for topic branches.

Copyright © 2010 James Golick, Protose, Inc. See LICENSE for details.

rollout's People

Contributors

jamesgolick avatar jnunemaker avatar michaeldwan avatar loe avatar

Stargazers

Mathieu Ravaux avatar  avatar

Watchers

James Cloos avatar  avatar

Forkers

onehub

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.