File tree 3 files changed +31
-1
lines changed
3 files changed +31
-1
lines changed Original file line number Diff line number Diff line change @@ -40,6 +40,9 @@ def self.brow_instances
40
40
# Public: net/http write timeout for all http requests (default: 5).
41
41
attr_accessor :write_timeout
42
42
43
+ # Public: Memoize adapter operations. Defaults to true.
44
+ attr_accessor :memoize
45
+
43
46
# Public: IO stream to send debug output too. Off by default.
44
47
#
45
48
# # for example, this would send all http request information to STDOUT
@@ -85,6 +88,7 @@ def initialize(options = {})
85
88
@sync_interval = options . fetch ( :sync_interval ) { ENV . fetch ( "FLIPPER_CLOUD_SYNC_INTERVAL" , 10 ) . to_f }
86
89
@sync_secret = options . fetch ( :sync_secret ) { ENV [ "FLIPPER_CLOUD_SYNC_SECRET" ] }
87
90
@local_adapter = options . fetch ( :local_adapter ) { Adapters ::Memory . new }
91
+ @memoize = options . fetch ( :memoize , true )
88
92
@debug_output = options [ :debug_output ]
89
93
@adapter_block = -> ( adapter ) { adapter }
90
94
self . url = options . fetch ( :url ) { ENV . fetch ( "FLIPPER_CLOUD_URL" , DEFAULT_URL ) }
Original file line number Diff line number Diff line change @@ -7,7 +7,10 @@ class DSL < SimpleDelegator
7
7
8
8
def initialize ( cloud_configuration )
9
9
@cloud_configuration = cloud_configuration
10
- super Flipper . new ( @cloud_configuration . adapter , instrumenter : @cloud_configuration . instrumenter )
10
+ super Flipper . new ( @cloud_configuration . adapter ,
11
+ instrumenter : @cloud_configuration . instrumenter ,
12
+ memoize : @cloud_configuration . memoize
13
+ )
11
14
end
12
15
13
16
def sync
Original file line number Diff line number Diff line change 79
79
expect ( enable_stub ) . to have_been_requested
80
80
end
81
81
end
82
+
83
+ context "when memoize = :poll" do
84
+ let ( :local_adapter ) do
85
+ Flipper ::Adapters ::OperationLogger . new Flipper ::Adapters ::Memory . new
86
+ end
87
+
88
+ let ( :cloud_configuration ) do
89
+ cloud_configuration = Flipper ::Cloud ::Configuration . new ( {
90
+ token : "asdf" ,
91
+ sync_secret : "tasty" ,
92
+ local_adapter : local_adapter ,
93
+ memoize : :poll
94
+ } )
95
+ end
96
+
97
+ subject do
98
+ described_class . new ( cloud_configuration )
99
+ end
100
+
101
+ it "uses a poll adaptor" do
102
+ expect ( subject . adapter ) . to be_a ( Flipper ::Adapters ::Poll )
103
+ end
104
+ end
82
105
end
You can’t perform that action at this time.
0 commit comments