@@ -76,21 +76,7 @@ def sync
7676 @adapter . import @remote_adapter
7777 @last_synced_at . update { |time | Concurrent . monotonic_time }
7878 ensure
79- if @remote_adapter . respond_to? ( :last_get_all_response ) && @remote_adapter . last_get_all_response
80- response = @remote_adapter . last_get_all_response
81-
82- if Flipper ::Typecast . to_boolean ( response [ "poll-shutdown" ] )
83- @shutdown_requested . make_true
84- @instrumenter . instrument ( "poller.#{ InstrumentationNamespace } " , {
85- operation : :shutdown_requested ,
86- } )
87- stop
88- end
89-
90- if interval = response [ "poll-interval" ]
91- self . interval = [ Flipper ::Typecast . to_float ( interval ) , @initial_interval ] . max
92- end
93- end
79+ apply_response_headers
9480 end
9581 end
9682 end
@@ -147,5 +133,25 @@ def reset
147133 @shutdown_requested . make_false
148134 mutex . unlock if mutex . locked?
149135 end
136+
137+ def apply_response_headers
138+ return unless @remote_adapter . respond_to? ( :last_get_all_response )
139+
140+ if response = @remote_adapter . last_get_all_response
141+ # shutdown based on response header
142+ if Flipper ::Typecast . to_boolean ( response [ "poll-shutdown" ] )
143+ @shutdown_requested . make_true
144+ @instrumenter . instrument ( "poller.#{ InstrumentationNamespace } " , {
145+ operation : :shutdown_requested ,
146+ } )
147+ stop
148+ end
149+
150+ # update interval based on response header
151+ if interval = response [ "poll-interval" ]
152+ self . interval = [ Flipper ::Typecast . to_float ( interval ) , @initial_interval ] . max
153+ end
154+ end
155+ end
150156 end
151157end
0 commit comments