Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions lib/flipper/poller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ def self.reset
instances.each {|_, instance| instance.stop }.clear
end

MINIMUM_POLL_INTERVAL = 10

def initialize(options = {})
@thread = nil
@pid = Process.pid
Expand All @@ -30,9 +32,9 @@ def initialize(options = {})
@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)
Expand Down Expand Up @@ -64,8 +66,7 @@ def run
# 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

Expand Down