Class: AmplitudeExperiment::FlagConfigPoller

Inherits:
Object
  • Object
show all
Defined in:
lib/experiment/local/poller.rb

Overview

FlagConfigPoller update the flag_config cache value

Constant Summary collapse

FLAG_CONFIG_POLLING_INTERVAL_MILLIS =
30_000

Instance Method Summary collapse

Constructor Details

#initialize(fetcher, cache, debug, poll_interval_millis: FLAG_CONFIG_POLLING_INTERVAL_MILLIS) ⇒ FlagConfigPoller

Returns a new instance of FlagConfigPoller.



7
8
9
10
11
12
13
14
15
# File 'lib/experiment/local/poller.rb', line 7

def initialize(fetcher, cache, debug, poll_interval_millis: FLAG_CONFIG_POLLING_INTERVAL_MILLIS)
  @fetcher = fetcher
  @cache = cache
  @poll_interval_millis = poll_interval_millis
  @logger = Logger.new($stdout)
  @debug = debug
  @poller_thread = nil
  @is_running = false
end

Instance Method Details

#startObject

Fetch initial flag configurations and start polling for updates. You must call this function to begin polling for flag config updates. Calling this function while the poller is already running does nothing.



20
21
22
23
24
25
# File 'lib/experiment/local/poller.rb', line 20

def start
  return if @is_running

  @logger.debug('[Experiment] poller - start') if @debug
  run
end

#stopObject

Stop polling for flag configurations. Calling this function while the poller is not running will do nothing.



29
30
31
32
33
# File 'lib/experiment/local/poller.rb', line 29

def stop
  @poller_thread&.exit
  @is_running = false
  @poller_thread = nil
end