Class: AmplitudeExperiment::FlagConfigPoller
- Inherits:
-
Object
- Object
- AmplitudeExperiment::FlagConfigPoller
- 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
-
#initialize(fetcher, cache, debug, poll_interval_millis: FLAG_CONFIG_POLLING_INTERVAL_MILLIS) ⇒ FlagConfigPoller
constructor
A new instance of FlagConfigPoller.
-
#start ⇒ Object
Fetch initial flag configurations and start polling for updates.
-
#stop ⇒ Object
Stop polling for flag configurations.
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
#start ⇒ Object
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 |
#stop ⇒ Object
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 |