Ruby Feature Switches / Feature Flippers
I have been inspired by how both Flickr and Disqus use feature switches. They both blogged about them and how they work on both of their development blogs.
I was just wondering if there was a Ruby gem i'm missing or if anyone knows of a way to do this in Ruby? If there isn't anything, I'd hope to make my own an开发者_StackOverflowd release it out in the wild. But I just wanted to ask here first because I haven't been able to find anything remotely similar to what both Flickr and Disqus achieve.
Check rollout if you're already using Redis.
I recently (9 Oct 14) took a look at the available gems - 9+ in various states of maintenance - and decided to go with Flipper. Rollout is also worth a look.
If you are looking to roll your own the source code for Rollout is only 200 lines and a good place to start. https://github.com/FetLife/rollout/blob/master/lib/rollout.rb
This railscast also has a barebones example http://railscasts.com/episodes/315-rollout-and-degrade
Also highly recommend the pattern. No gems that I know of, but it's pretty easy to do. One tip: include the ability to auto-set the initial state to either on or off:
feature_flag('third_party_tool', :default => true) do
... # this is on by default
end
This will save you headaches at deployment time.
Here's a few more:
- https://github.com/qype/feature_flipper
- https://github.com/grillpanda/dolphin
I tried all the flipper gems available now (March 2015) and chose the ruby_flipper
Yes, it is older than others, but it allows you to use blocks and arguments to calculate feature state, and it is damn simple.
It does not require redis, any database or anything else.
For multi-server setup I use ENV variables. It's actually possible to use anything since it does not limit you (like the other options here do).
The only thing I don't like is that ruby_flipper
pollutes Object with its methods, but that is easy to solve.
To summarize: if you need a lightweight, configurable and not limited solution, I vote for this simple gem.
Others are good in some specific area, this one is good to start with.
Another good candidate is rollout mentioned in accepted answer.
精彩评论