Sha256: e4e1f95a164f7fc5a5fb6f3004d25b4ddbf245314ee2e9be8258d34a52f82841

Contents?: true

Size: 1.18 KB

Versions: 10

Compression:

Stored size: 1.18 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, :batch

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

        protected

        def metadata
          {
            s: "#{SplitIoClient.configuration.language}-#{SplitIoClient.configuration.version}",
            i: SplitIoClient.configuration.machine_ip,
            n: SplitIoClient.configuration.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

10 entries across 10 versions & 1 rubygems

Version Path
splitclient-rb-6.3.0-java lib/splitclient-rb/cache/repositories/events_repository.rb
splitclient-rb-6.3.0 lib/splitclient-rb/cache/repositories/events_repository.rb
splitclient-rb-6.3.0.pre.rc1-java lib/splitclient-rb/cache/repositories/events_repository.rb
splitclient-rb-6.3.0.pre.rc1 lib/splitclient-rb/cache/repositories/events_repository.rb
splitclient-rb-6.2.0-java lib/splitclient-rb/cache/repositories/events_repository.rb
splitclient-rb-6.2.0 lib/splitclient-rb/cache/repositories/events_repository.rb
splitclient-rb-6.2.0.pre.rc2-java lib/splitclient-rb/cache/repositories/events_repository.rb
splitclient-rb-6.2.0.pre.rc2 lib/splitclient-rb/cache/repositories/events_repository.rb
splitclient-rb-6.2.0.pre.rc1-java lib/splitclient-rb/cache/repositories/events_repository.rb
splitclient-rb-6.2.0.pre.rc1 lib/splitclient-rb/cache/repositories/events_repository.rb