Class: Flagsmith::EnvironmentDataPollingManager
- Inherits:
-
Object
- Object
- Flagsmith::EnvironmentDataPollingManager
- Includes:
- SDK::Intervals
- Defined in:
- lib/flagsmith/sdk/pooling_manager.rb
Overview
Manager to asynchronously fetch the environment
Instance Attribute Summary collapse
-
#failures_since_last_update ⇒ Object
readonly
Returns the value of attribute failures_since_last_update.
Instance Method Summary collapse
-
#initialize(main, refresh_interval_seconds, polling_manager_failure_limit) ⇒ EnvironmentDataPollingManager
constructor
A new instance of EnvironmentDataPollingManager.
-
#start ⇒ Object
rubocop:disable Metrics/MethodLength.
-
#stop ⇒ Object
rubocop:enable Metrics/MethodLength.
Methods included from SDK::Intervals
#clear_interval, #set_interval
Constructor Details
#initialize(main, refresh_interval_seconds, polling_manager_failure_limit) ⇒ EnvironmentDataPollingManager
Returns a new instance of EnvironmentDataPollingManager.
12 13 14 15 16 17 |
# File 'lib/flagsmith/sdk/pooling_manager.rb', line 12 def initialize(main, refresh_interval_seconds, polling_manager_failure_limit) @main = main @refresh_interval_seconds = refresh_interval_seconds @polling_manager_failure_limit = polling_manager_failure_limit @failures_since_last_update = 0 end |
Instance Attribute Details
#failures_since_last_update ⇒ Object (readonly)
Returns the value of attribute failures_since_last_update.
10 11 12 |
# File 'lib/flagsmith/sdk/pooling_manager.rb', line 10 def failures_since_last_update @failures_since_last_update end |
Instance Method Details
#start ⇒ Object
rubocop:disable Metrics/MethodLength
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/flagsmith/sdk/pooling_manager.rb', line 20 def start update_environment = lambda { stop @interval = set_interval(@refresh_interval_seconds) do @main.update_environment @failures_since_last_update = 0 rescue StandardError => e @failures_since_last_update += 1 @main.config.logger.warn "Failure to update the environment due to an error: #{e}" raise e if @failures_since_last_update > @polling_manager_failure_limit end } # TODO: this call should be awaited for getIdentityFlags/getEnvironmentFlags when enableLocalEvaluation is true update_environment.call end |
#stop ⇒ Object
rubocop:enable Metrics/MethodLength
38 39 40 41 42 |
# File 'lib/flagsmith/sdk/pooling_manager.rb', line 38 def stop return unless @interval clear_interval(@interval) end |