Sha256: 7a0e7f041bf844ba69ba159001ff1b68358292842a21cf405c45f54160f91020

Contents?: true

Size: 1.14 KB

Versions: 29

Compression:

Stored size: 1.14 KB

Contents

module SplitIoClient
  module Cache
    module Repositories
      # Repository which forwards events interface to the selected adapter
      class EventsRepository < Repository
        extend Forwardable
        def_delegators :@adapter, :add, :clear

        def initialize(adapter, config)
          @config = config
          @adapter = case adapter.class.to_s
          when 'SplitIoClient::Cache::Adapters::MemoryAdapter'
            Repositories::Events::MemoryRepository.new(adapter, config)
          when 'SplitIoClient::Cache::Adapters::RedisAdapter'
            Repositories::Events::RedisRepository.new(adapter, config)
          end
        end

        protected

        def metadata
          {
            s: "#{@config.language}-#{@config.version}",
            i: @config.machine_ip,
            n: @config.machine_name
          }
        end

        def event(key, traffic_type, event_type, time, value)
          {
            key: key,
            trafficTypeName: traffic_type,
            eventTypeId: event_type,
            value: value,
            timestamp: time
          }.reject { |_, v| v.nil? }
        end
      end
    end
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
splitclient-rb-5.1.0-java lib/splitclient-rb/cache/repositories/events_repository.rb
splitclient-rb-5.1.0 lib/splitclient-rb/cache/repositories/events_repository.rb
splitclient-rb-5.1.0.pre.rc1-java lib/splitclient-rb/cache/repositories/events_repository.rb
splitclient-rb-5.1.0.pre.rc1 lib/splitclient-rb/cache/repositories/events_repository.rb
splitclient-rb-5.0.3-java lib/splitclient-rb/cache/repositories/events_repository.rb
splitclient-rb-5.0.3 lib/splitclient-rb/cache/repositories/events_repository.rb
splitclient-rb-5.0.3.pre.rc1-java lib/splitclient-rb/cache/repositories/events_repository.rb
splitclient-rb-5.0.3.pre.rc1 lib/splitclient-rb/cache/repositories/events_repository.rb
splitclient-rb-5.0.2-java lib/splitclient-rb/cache/repositories/events_repository.rb
splitclient-rb-5.0.2 lib/splitclient-rb/cache/repositories/events_repository.rb
splitclient-rb-5.0.2.pre.rc1-java lib/splitclient-rb/cache/repositories/events_repository.rb
splitclient-rb-5.0.2.pre.rc1 lib/splitclient-rb/cache/repositories/events_repository.rb
splitclient-rb-5.0.1-java lib/splitclient-rb/cache/repositories/events_repository.rb
splitclient-rb-5.0.1 lib/splitclient-rb/cache/repositories/events_repository.rb
splitclient-rb-5.0.1.pre.rc1-java lib/splitclient-rb/cache/repositories/events_repository.rb
splitclient-rb-5.0.1.pre.rc1 lib/splitclient-rb/cache/repositories/events_repository.rb
splitclient-rb-5.0.0-java lib/splitclient-rb/cache/repositories/events_repository.rb
splitclient-rb-5.0.0 lib/splitclient-rb/cache/repositories/events_repository.rb
splitclient-rb-5.0.0.pre.rc1-java lib/splitclient-rb/cache/repositories/events_repository.rb
splitclient-rb-5.0.0.pre.rc1 lib/splitclient-rb/cache/repositories/events_repository.rb