lib/flipper/poller.rb in flipper-1.2.2 vs lib/flipper/poller.rb in flipper-1.3.0.pre
- old
+ new
@@ -18,23 +18,25 @@
def self.reset
instances.each {|_, instance| instance.stop }.clear
end
+ MINIMUM_POLL_INTERVAL = 10
+
def initialize(options = {})
@thread = nil
@pid = Process.pid
@mutex = Mutex.new
@instrumenter = options.fetch(:instrumenter, Instrumenters::Noop)
@remote_adapter = options.fetch(:remote_adapter)
@interval = options.fetch(:interval, 10).to_f
@last_synced_at = Concurrent::AtomicFixnum.new(0)
@adapter = Adapters::Memory.new(nil, threadsafe: true)
- if @interval < 1
- warn "Flipper::Cloud poll interval must be greater than or equal to 1 but was #{@interval}. Setting @interval to 1."
- @interval = 1
+ if @interval < MINIMUM_POLL_INTERVAL
+ warn "Flipper::Cloud poll interval must be greater than or equal to #{MINIMUM_POLL_INTERVAL} but was #{@interval}. Setting @interval to #{MINIMUM_POLL_INTERVAL}."
+ @interval = MINIMUM_POLL_INTERVAL
end
@start_automatically = options.fetch(:start_automatically, true)
if options.fetch(:shutdown_automatically, true)
@@ -62,11 +64,10 @@
sync
rescue => exception
# you can instrument these using poller.flipper
end
- sleep_interval = interval - (Concurrent.monotonic_time - start)
- sleep sleep_interval if sleep_interval.positive?
+ sleep interval
end
end
def sync
@instrumenter.instrument("poller.#{InstrumentationNamespace}", operation: :poll) do