Sha256: a77e5975de27f5120dff3287feb8b0f696ce4828228170c177a697cd33aa9ba7
Contents?: true
Size: 1.7 KB
Versions: 3
Compression:
Stored size: 1.7 KB
Contents
require "flipper/feature" require "flipper/gate_values" require "flipper/instrumenters/noop" require "flipper/adapters/sync/feature_synchronizer" module Flipper module Adapters class Sync # Internal: Given a local and remote adapter, it can update the local to # match the remote doing only the necessary enable/disable operations. class Synchronizer def initialize(local, remote, options = {}) @local = local @remote = remote @instrumenter = options.fetch(:instrumenter, Instrumenters::Noop) end def call @instrumenter.instrument("synchronizer_call.flipper") { sync } end private def sync local_get_all = @local.get_all # TODO: Move remote get all to background thread to minimize impact to # whatever is happening in main thread. remote_get_all = @remote.get_all # Sync all the gate values. remote_get_all.each do |feature_key, remote_gates_hash| feature = Feature.new(feature_key, @local) local_gates_hash = local_get_all[feature_key] || @local.default_config local_gate_values = GateValues.new(local_gates_hash) remote_gate_values = GateValues.new(remote_gates_hash) FeatureSynchronizer.new(feature, local_gate_values, remote_gate_values).call end # Add features that are missing features_to_add = remote_get_all.keys - local_get_all.keys features_to_add.each { |key| Feature.new(key, @local).add } rescue => exception @instrumenter.instrument("synchronizer_exception.flipper", exception: exception) end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
flipper-0.14.0 | lib/flipper/adapters/sync/synchronizer.rb |
flipper-0.13.0 | lib/flipper/adapters/sync/synchronizer.rb |
flipper-0.13.0.beta1 | lib/flipper/adapters/sync/synchronizer.rb |