Partially release your features.
Working with Docker
docker-compose run feature_flagger
docker-compose run feature_flagger rspec
Add this line to your application's Gemfile:
And then execute:
Or install it yourself as:
$ gem install feature_flagger
By default, feature_flagger uses the REDIS_URL env var to setup it's storage.
You can set up FeatureFlagger by creating a file called
config/initializers/feature_flagger with the following lines:
require 'redis-namespace' require 'feature_flagger' FeatureFlagger.configure do |config| redis = Redis.new(host: ENV['REDIS_URL']) namespaced = Redis::Namespace.new('feature_flagger', redis: redis) config.storage = FeatureFlagger::Storage::Redis.new(namespaced) end
- Create a
rollout.ymlin config path and declare a rollout:
account: # model name email_marketing: # namespace (optional) new_email_flow: # feature key description: @dispatch team uses this rollout to introduce a new email flow for certains users. Read more at [link]
- Adds rollout funcionality to your model:
class Account < ActiveRecord::Base include FeatureFlagger::Model # .... end
account = Account.first # Release feature for account account.release(:email_marketing, :new_email_flow) #=> true # Check feature for a given account account.released?(:email_marketing, :new_email_flow) #=> true # Remove feature for given account account.unrelease(:email_marketing, :new_email_flow) #=> true # If you try to check an inexistent rollout key it will raise an error. account.released?(:email_marketing, :new_email_flow) FeatureFlagger::KeyNotFoundError: ["account", "email_marketing", "new_email_flo"] # Check feature for a specific account id Account.released_id?(42, :email_marketing, :new_email_flow) #=> true # Release a feature for a specific account id Account.release_id(42, :email_marketing, :new_email_flow) #=> true # Get an array with all released Account ids Account.all_released_ids_for(:email_marketing, :new_email_flow) # Releasing a feature to all accounts Account.release_to_all(:email_marketing, :new_email_flow) # Unreleasing a feature to all accounts Account.unrelease_to_all(:email_marketing, :new_email_flow) # Return an array with all features released for all Account.released_features_to_all
Clean up action
By default when a key is removed from
rollout.yml file, its data still in the storage.
To clean it up, execute or schedule the rake:
$ bundle exec rake feature_flagger:cleanup_removed_rollouts
Bug reports and pull requests are welcome! Please take a look at our guidelines here.