Class: FeatureFlagger::Storage::FeatureKeysMigration

Inherits:
Object
  • Object
show all
Defined in:
lib/feature_flagger/storage/feature_keys_migration.rb

Instance Method Summary collapse

Constructor Details

#initialize(from_redis, to_control) ⇒ FeatureKeysMigration

Returns a new instance of FeatureKeysMigration.



7
8
9
10
# File 'lib/feature_flagger/storage/feature_keys_migration.rb', line 7

def initialize(from_redis, to_control)
  @from_redis = from_redis
  @to_control = to_control
end

Instance Method Details

#callObject

call migrates features key from the old fashioned to the new format.

It must replicate feature keys with changes:

from “avenue:traffic_lights” => 42 to “avenue:42” => traffic_lights



19
20
21
22
23
24
25
26
# File 'lib/feature_flagger/storage/feature_keys_migration.rb', line 19

def call
  @from_redis.scan_each(match: "*", count: FeatureFlagger::Storage::Redis::SCAN_EACH_BATCH_SIZE) do |redis_key|
    # filter out resource_keys
    next if redis_key.start_with?("#{FeatureFlagger::Storage::Redis::RESOURCE_PREFIX}:")

    migrate_key(redis_key)
  end
end