File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed
Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -7,20 +7,31 @@ module Flagsmith
77 class EnvironmentDataPollingManager
88 include Flagsmith ::SDK ::Intervals
99
10- def initialize ( main , refresh_interval_seconds )
10+ def initialize ( main , refresh_interval_seconds , polling_manager_failure_limit )
1111 @main = main
1212 @refresh_interval_seconds = refresh_interval_seconds
13+ @polling_manager_failure_limit = polling_manager_failure_limit
14+ @failures_since_last_update = 0
1315 end
1416
17+ # rubocop:disable Metrics/MethodLength
1518 def start
1619 update_environment = lambda {
1720 stop
18- @interval = set_interval ( @refresh_interval_seconds ) { @main . update_environment }
21+ @interval = set_interval ( @refresh_interval_seconds ) do
22+ @main . update_environment
23+ @failures_since_last_update = 0
24+ rescue StandardError => e
25+ @failures_since_last_update += 1
26+ @main . config . logger . warn "Failure to update the environment due to an error: #{ e } "
27+ raise e if @failures_since_last_update > @polling_manager_failure_limit
28+ end
1929 }
2030
2131 # TODO: this call should be awaited for getIdentityFlags/getEnvironmentFlags when enableLocalEvaluation is true
2232 update_environment . call
2333 end
34+ # rubocop:enable Metrics/MethodLength
2435
2536 def stop
2637 return unless @interval
You can’t perform that action at this time.
0 commit comments