class GoFlippy::Poller
Public Class Methods
new(polling_interval, http_client, store)
click to toggle source
# File lib/goflippy-ruby/poller.rb, line 5 def initialize(polling_interval, http_client, store) @polling_interval = polling_interval @http_client = http_client @store = store end
Public Instance Methods
start()
click to toggle source
# File lib/goflippy-ruby/poller.rb, line 11 def start Logger.debug('Start polling worker process') Worker.create(@polling_interval) do keys = [] @http_client.get('/features')&.each do |feature| uids = @store.find(feature[:key]) uids.each do |uid| enabled = @http_client.get("/users/#{uid}/features/#{key}")&.dig(:enabled) @store.put(feature[:key], { uid: uid.to_sym, enabled: enabled }) end keys << feature[:key] end Logger.info("Polling finished. #{keys.inspect}") @store.refresh!(keys) end end