Sha256: 2e68d533415e81f1ac05cc930d836a6caac84c773bdcaf980d5996e7ff251b61

Contents?: true

Size: 903 Bytes

Versions: 28

Compression:

Stored size: 903 Bytes

Contents

module SplitIoClient
  module Cache
    module Repositories
      module Events
        class MemoryRepository < EventsRepository
          EVENTS_MAX_SIZE_BYTES = 5242880

          def initialize(config)
            @config = config
            @adapter = @config.events_adapter
            @size = 0
          end

          def add(key, traffic_type, event_type, time, value, properties, event_size)
            @adapter.add_to_queue(m: metadata, e: event(key, traffic_type, event_type, time, value, properties))
            @size += event_size

            post_events if @size >= EVENTS_MAX_SIZE_BYTES || @adapter.length == @config.events_queue_size

            rescue StandardError => error
              @config.log_found_exception(__method__.to_s, error)
          end

          def clear
            @size = 0
            @adapter.clear
          end
        end
      end
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
splitclient-rb-7.0.2-java lib/splitclient-rb/cache/repositories/events/memory_repository.rb
splitclient-rb-7.0.2 lib/splitclient-rb/cache/repositories/events/memory_repository.rb
splitclient-rb-7.0.2.pre.rc2-java lib/splitclient-rb/cache/repositories/events/memory_repository.rb
splitclient-rb-7.0.2.pre.rc2 lib/splitclient-rb/cache/repositories/events/memory_repository.rb
splitclient-rb-7.0.2.pre.rc1-java lib/splitclient-rb/cache/repositories/events/memory_repository.rb
splitclient-rb-7.0.2.pre.rc1 lib/splitclient-rb/cache/repositories/events/memory_repository.rb
splitclient-rb-7.0.1-java lib/splitclient-rb/cache/repositories/events/memory_repository.rb
splitclient-rb-7.0.1 lib/splitclient-rb/cache/repositories/events/memory_repository.rb
splitclient-rb-7.0.1.pre.rc7-java lib/splitclient-rb/cache/repositories/events/memory_repository.rb
splitclient-rb-7.0.1.pre.rc7 lib/splitclient-rb/cache/repositories/events/memory_repository.rb
splitclient-rb-7.0.1.pre.rc6-java lib/splitclient-rb/cache/repositories/events/memory_repository.rb
splitclient-rb-7.0.1.pre.rc6 lib/splitclient-rb/cache/repositories/events/memory_repository.rb
splitclient-rb-7.0.1.pre.rc5-java lib/splitclient-rb/cache/repositories/events/memory_repository.rb
splitclient-rb-7.0.1.pre.rc5 lib/splitclient-rb/cache/repositories/events/memory_repository.rb
splitclient-rb-7.0.1.pre.rc4-java lib/splitclient-rb/cache/repositories/events/memory_repository.rb
splitclient-rb-7.0.1.pre.rc4 lib/splitclient-rb/cache/repositories/events/memory_repository.rb
splitclient-rb-7.0.1.pre.rc3-java lib/splitclient-rb/cache/repositories/events/memory_repository.rb
splitclient-rb-7.0.1.pre.rc3 lib/splitclient-rb/cache/repositories/events/memory_repository.rb
splitclient-rb-7.0.1.pre.rc1-java lib/splitclient-rb/cache/repositories/events/memory_repository.rb
splitclient-rb-7.0.1.pre.rc1 lib/splitclient-rb/cache/repositories/events/memory_repository.rb