Sha256: 39ac389407f407bbe74c6b9a258e67f13a78ac41fc8d8e189d708b07b15d9b76
Contents?: true
Size: 1.33 KB
Versions: 2
Compression:
Stored size: 1.33 KB
Contents
require "concurrent/atomics" require "thread" module LaunchDarkly class PollingProcessor def initialize(config, requestor) @config = config @requestor = requestor @initialized = Concurrent::AtomicBoolean.new(false) @started = Concurrent::AtomicBoolean.new(false) end def initialized? @initialized.value end def start return unless @started.make_true @config.logger.info("[LDClient] Initializing polling connection") create_worker end def poll flags = @requestor.request_all_flags if flags @config.feature_store.init(flags) if @initialized.make_true @config.logger.info("[LDClient] Polling connection initialized") end end end def create_worker Thread.new do @config.logger.debug("[LDClient] Starting polling worker") loop do begin started_at = Time.now poll delta = @config.poll_interval - (Time.now - started_at) if delta > 0 sleep(delta) end rescue StandardError => exn @config.logger.error("[LDClient] Exception while polling: #{exn.inspect}") # TODO: log_exception(__method__.to_s, exn) end end end end private :poll, :create_worker end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ldclient-rb-2.2.7 | lib/ldclient-rb/polling.rb |
ldclient-rb-2.2.6 | lib/ldclient-rb/polling.rb |