Class: Flipper::Adapters::DualWrite

Inherits:
Object
  • Object
show all
Includes:
Flipper::Adapter
Defined in:
lib/flipper/adapters/dual_write.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Flipper::Adapter

#default_config, #export, #import, included, #name, #read_only?

Constructor Details

#initialize(local, remote, options = {}) ⇒ DualWrite

Public: Build a new sync instance.

local - The local flipper adapter that should serve reads. remote - The remote flipper adapter that writes should go to first (in

addition to the local adapter).


13
14
15
16
# File 'lib/flipper/adapters/dual_write.rb', line 13

def initialize(local, remote, options = {})
  @local = local
  @remote = remote
end

Instance Attribute Details

#localObject (readonly)

Returns the value of attribute local.



6
7
8
# File 'lib/flipper/adapters/dual_write.rb', line 6

def local
  @local
end

#remoteObject (readonly)

Returns the value of attribute remote.



6
7
8
# File 'lib/flipper/adapters/dual_write.rb', line 6

def remote
  @remote
end

Instance Method Details

#adapter_stackObject



18
19
20
# File 'lib/flipper/adapters/dual_write.rb', line 18

def adapter_stack
  "#{name}(local: #{@local.adapter_stack}, remote: #{@remote.adapter_stack})"
end

#add(feature) ⇒ Object



38
39
40
# File 'lib/flipper/adapters/dual_write.rb', line 38

def add(feature)
  @remote.add(feature).tap { @local.add(feature) }
end

#clear(feature) ⇒ Object



46
47
48
# File 'lib/flipper/adapters/dual_write.rb', line 46

def clear(feature)
  @remote.clear(feature).tap { @local.clear(feature) }
end

#disable(feature, gate, thing) ⇒ Object



56
57
58
59
60
# File 'lib/flipper/adapters/dual_write.rb', line 56

def disable(feature, gate, thing)
  @remote.disable(feature, gate, thing).tap do
    @local.disable(feature, gate, thing)
  end
end

#enable(feature, gate, thing) ⇒ Object



50
51
52
53
54
# File 'lib/flipper/adapters/dual_write.rb', line 50

def enable(feature, gate, thing)
  @remote.enable(feature, gate, thing).tap do
    @local.enable(feature, gate, thing)
  end
end

#featuresObject



22
23
24
# File 'lib/flipper/adapters/dual_write.rb', line 22

def features
  @local.features
end

#get(feature) ⇒ Object



26
27
28
# File 'lib/flipper/adapters/dual_write.rb', line 26

def get(feature)
  @local.get(feature)
end

#get_all(**kwargs) ⇒ Object



34
35
36
# File 'lib/flipper/adapters/dual_write.rb', line 34

def get_all(**kwargs)
  @local.get_all(**kwargs)
end

#get_multi(features) ⇒ Object



30
31
32
# File 'lib/flipper/adapters/dual_write.rb', line 30

def get_multi(features)
  @local.get_multi(features)
end

#remove(feature) ⇒ Object



42
43
44
# File 'lib/flipper/adapters/dual_write.rb', line 42

def remove(feature)
  @remote.remove(feature).tap { @local.remove(feature) }
end