Skip to content

Commit

Permalink
Add cleanup detached rake (#52)
Browse files Browse the repository at this point in the history
* Add cleanup detached rake test
  • Loading branch information
felipeetchatz authored and Nando Sousa committed Apr 30, 2019
1 parent 00971a2 commit be972a4
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 0 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,14 @@ Account.unrelease_to_all(:email_marketing, :new_email_flow)
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

## Contributing

Bug reports and pull requests are welcome!
Expand Down
1 change: 1 addition & 0 deletions lib/feature_flagger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
require 'feature_flagger/feature'
require 'feature_flagger/configuration'
require 'feature_flagger/manager'
require 'feature_flagger/railtie'

module FeatureFlagger
class << self
Expand Down
9 changes: 9 additions & 0 deletions lib/feature_flagger/railtie.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
if defined?(Rails)
module FeatureFlagger
class Railtie < Rails::Railtie
rake_tasks do
load 'tasks/cleanup.rake'
end
end
end
end
10 changes: 10 additions & 0 deletions lib/tasks/cleanup.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace :feature_flagger do
desc "cleaning up keys from storage that are no longer in the rollout.yml file"
task :cleanup_removed_rollouts => :environment do
keys = FeatureFlagger::Manager.detached_feature_keys
puts "Found keys to remove: #{keys}"
keys.each do |key|
FeatureFlagger::Manager.cleanup_detached key
end
end
end

0 comments on commit be972a4

Please sign in to comment.