Sha256: 48e095764d17f0e433f157fadf09884d5a3e656ddc0c7176282e6859ac0e696e

Contents?: true

Size: 903 Bytes

Versions: 10

Compression:

Stored size: 903 Bytes

Contents

require 'flipper/adapters/sync/synchronizer'
require 'flipper/poller'

module Flipper
  module Adapters
    class Poll
      extend Forwardable
      include ::Flipper::Adapter

      # Deprecated
      Poller = ::Flipper::Poller

      attr_reader :adapter, :poller

      def_delegators :synced_adapter, :features, :get, :get_multi, :get_all, :add, :remove, :clear, :enable, :disable

      def initialize(poller, adapter)
        @adapter = adapter
        @poller = poller
        @last_synced_at = 0
        @poller.start
      end

      private

      def synced_adapter
        @poller.start
        poller_last_synced_at = @poller.last_synced_at.value
        if poller_last_synced_at > @last_synced_at
          Flipper::Adapters::Sync::Synchronizer.new(@adapter, @poller.adapter).call
          @last_synced_at = poller_last_synced_at
        end
        @adapter
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
flipper-1.3.2 lib/flipper/adapters/poll.rb
flipper-1.3.1 lib/flipper/adapters/poll.rb
flipper-1.3.0 lib/flipper/adapters/poll.rb
flipper-1.3.0.pre lib/flipper/adapters/poll.rb
flipper-1.2.2 lib/flipper/adapters/poll.rb
flipper-1.2.1 lib/flipper/adapters/poll.rb
flipper-1.2.0 lib/flipper/adapters/poll.rb
flipper-1.1.2 lib/flipper/adapters/poll.rb
flipper-1.1.1 lib/flipper/adapters/poll.rb
flipper-1.1.0 lib/flipper/adapters/poll.rb