File tree Expand file tree Collapse file tree 4 files changed +33
-2
lines changed Expand file tree Collapse file tree 4 files changed +33
-2
lines changed Original file line number Diff line number Diff line change @@ -40,6 +40,9 @@ def self.brow_instances
4040 # Public: net/http write timeout for all http requests (default: 5).
4141 attr_accessor :write_timeout
4242
43+ # Public: Memoize adapter operations. Defaults to true.
44+ attr_accessor :memoize
45+
4346 # Public: IO stream to send debug output too. Off by default.
4447 #
4548 # # for example, this would send all http request information to STDOUT
@@ -85,6 +88,7 @@ def initialize(options = {})
8588 @sync_interval = options . fetch ( :sync_interval ) { ENV . fetch ( "FLIPPER_CLOUD_SYNC_INTERVAL" , 10 ) . to_f }
8689 @sync_secret = options . fetch ( :sync_secret ) { ENV [ "FLIPPER_CLOUD_SYNC_SECRET" ] }
8790 @local_adapter = options . fetch ( :local_adapter ) { Adapters ::Memory . new }
91+ @memoize = options . fetch ( :memoize , true )
8892 @debug_output = options [ :debug_output ]
8993 @adapter_block = -> ( adapter ) { adapter }
9094 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
77
88 def initialize ( cloud_configuration )
99 @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+ )
1114 end
1215
1316 def sync
Original file line number Diff line number Diff line change @@ -15,7 +15,8 @@ class Engine < Rails::Engine
1515 if ENV [ "FLIPPER_CLOUD_TOKEN" ]
1616 Flipper ::Cloud . new (
1717 local_adapter : config . adapter ,
18- instrumenter : app . config . flipper . instrumenter
18+ instrumenter : app . config . flipper . instrumenter ,
19+ memoize : app . config . flipper . memoize
1920 )
2021 else
2122 warn "Missing FLIPPER_CLOUD_TOKEN environment variable. Disabling Flipper::Cloud."
Original file line number Diff line number Diff line change 7979 expect ( enable_stub ) . to have_been_requested
8080 end
8181 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
82105end
You can’t perform that action at this time.
0 commit comments