-
-
Notifications
You must be signed in to change notification settings - Fork 411
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
282dfb3
commit 48cf8e0
Showing
1 changed file
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
require 'bundler/setup' | ||
require_relative 'active_record/ar_setup' | ||
require 'flipper' | ||
require 'flipper/adapters/redis' | ||
require 'flipper/adapters/active_record' | ||
|
||
# Say you have production... | ||
production_adapter = Flipper::Adapters::Memory.new | ||
production = Flipper.new(production_adapter) | ||
|
||
# And production has some stuff enabled... | ||
production.enable(:search) | ||
production.enable_percentage_of_time(:verbose_logging, 5) | ||
production.enable_percentage_of_actors(:new_feature, 5) | ||
production.enable_actor(:issues, Flipper::Actor.new('1')) | ||
production.enable_actor(:issues, Flipper::Actor.new('2')) | ||
production.enable_group(:request_tracing, :staff) | ||
|
||
# And you would like to mirror production to staging... | ||
staging_adapter = Flipper::Adapters::Memory.new | ||
staging = Flipper.new(staging_adapter) | ||
staging_export = staging.export | ||
|
||
puts "Here is the state of the world for staging and production..." | ||
puts "Staging" | ||
staging.features.each do |feature| | ||
pp feature: feature.key, values: feature.gate_values | ||
end | ||
puts "Production" | ||
production.features.each do |feature| | ||
pp feature: feature.key, values: feature.gate_values | ||
end | ||
|
||
# NOTE: This wipes active record clean and copies features/gates from redis into active record. | ||
puts "Mirroring production to staging..." | ||
staging.import(production.export) | ||
puts "Staging is now identical to Production." | ||
|
||
puts "Staging" | ||
staging.features.each do |feature| | ||
pp feature: feature.key, values: feature.gate_values | ||
end | ||
puts "Production" | ||
production.features.each do |feature| | ||
pp feature: feature.key, values: feature.gate_values | ||
end | ||
|
||
puts "Restoring staging to original state..." | ||
staging.import(staging_export) | ||
puts "Staging restored." | ||
|
||
puts "Staging" | ||
staging.features.each do |feature| | ||
pp feature: feature.key, values: feature.gate_values | ||
end | ||
puts "Production" | ||
production.features.each do |feature| | ||
pp feature: feature.key, values: feature.gate_values | ||
end |