class Flipper::Adapters::Sync
TODO: Syncing should happen in a background thread on a regular interval rather than in the main thread only when reads happen.
Attributes
name[R]
Public: The name of the adapter.
synchronizer[R]
Public: The synchronizer that will keep the local and remote in sync.
Public Class Methods
new(local, remote, options = {})
click to toggle source
Public: Build a new sync instance.
local - The local flipper adapter that should serve reads. remote - The remote flipper adapter that should serve writes and update
the local on an interval.
interval - The Float or Integer number of seconds between syncs from remote to local. Default value is set in IntervalSynchronizer
.
# File lib/flipper/adapters/sync.rb, line 24 def initialize(local, remote, options = {}) @name = :sync @local = local @remote = remote @synchronizer = options.fetch(:synchronizer) do sync_options = { raise: false, } instrumenter = options[:instrumenter] sync_options[:instrumenter] = instrumenter if instrumenter synchronizer = Synchronizer.new(@local, @remote, sync_options) IntervalSynchronizer.new(synchronizer, interval: options[:interval]) end synchronize end
Public Instance Methods
add(feature)
click to toggle source
# File lib/flipper/adapters/sync.rb, line 60 def add(feature) result = @remote.add(feature) @local.add(feature) result end
clear(feature)
click to toggle source
# File lib/flipper/adapters/sync.rb, line 72 def clear(feature) result = @remote.clear(feature) @local.clear(feature) result end
disable(feature, gate, thing)
click to toggle source
# File lib/flipper/adapters/sync.rb, line 84 def disable(feature, gate, thing) result = @remote.disable(feature, gate, thing) @local.disable(feature, gate, thing) result end
enable(feature, gate, thing)
click to toggle source
# File lib/flipper/adapters/sync.rb, line 78 def enable(feature, gate, thing) result = @remote.enable(feature, gate, thing) @local.enable(feature, gate, thing) result end
features()
click to toggle source
# File lib/flipper/adapters/sync.rb, line 40 def features synchronize @local.features end
get(feature)
click to toggle source
# File lib/flipper/adapters/sync.rb, line 45 def get(feature) synchronize @local.get(feature) end
get_all()
click to toggle source
# File lib/flipper/adapters/sync.rb, line 55 def get_all synchronize @local.get_all end
get_multi(features)
click to toggle source
# File lib/flipper/adapters/sync.rb, line 50 def get_multi(features) synchronize @local.get_multi(features) end
remove(feature)
click to toggle source
# File lib/flipper/adapters/sync.rb, line 66 def remove(feature) result = @remote.remove(feature) @local.remove(feature) result end
Private Instance Methods
synchronize()
click to toggle source
# File lib/flipper/adapters/sync.rb, line 92 def synchronize @synchronizer.call end