Sha256: 5835fe8432c8309d588503c823108eb17d5568aaeb5f2f92d35d55d9f51e7914

Contents?: true

Size: 757 Bytes

Versions: 8

Compression:

Stored size: 757 Bytes

Contents

# frozen_string_literal: true

require_relative 'intervals'

module Flagsmith
  # Manager to asynchronously fetch the environment
  class EnvironmentDataPollingManager
    include Flagsmith::SDK::Intervals

    def initialize(main, refresh_interval_seconds)
      @main = main
      @refresh_interval_seconds = refresh_interval_seconds
    end

    def start
      update_environment = lambda {
        stop
        @interval = set_interval(@refresh_interval_seconds) { @main.update_environment }
      }

      # TODO: this call should be awaited for getIdentityFlags/getEnvironmentFlags when enableLocalEvaluation is true
      update_environment.call
    end

    def stop
      return unless @interval

      clear_interval(@interval)
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
flagsmith-4.1.0 lib/flagsmith/sdk/pooling_manager.rb
flagsmith-4.0.1 lib/flagsmith/sdk/pooling_manager.rb
flagsmith-4.0.0 lib/flagsmith/sdk/pooling_manager.rb
flagsmith-3.2.0 lib/flagsmith/sdk/pooling_manager.rb
flagsmith-3.1.1 lib/flagsmith/sdk/pooling_manager.rb
flagsmith-3.1.0 lib/flagsmith/sdk/pooling_manager.rb
flagsmith-3.0.1 lib/flagsmith/sdk/pooling_manager.rb
flagsmith-3.0.0 lib/flagsmith/sdk/pooling_manager.rb