Sha256: a757cb36d6dcb24c698da2ba727796fcbc3c005ffc82d6f51e7dd386d548c50e
Contents?: true
Size: 1.21 KB
Versions: 6
Compression:
Stored size: 1.21 KB
Contents
module SplitIoClient module Cache module Repositories module Impressions class MemoryRepository def initialize(adapter, config) @adapter = adapter @config = config end # Store impression data in the selected adapter def add(split_name, data) @adapter.add_to_queue(feature: split_name, impressions: data) rescue ThreadError # queue is full if random_sampler.rand(1..1000) <= 2 # log only 0.2 % of the time @config.logger.warn("Dropping impressions. Current size is #{@config.impressions_queue_size}. " \ "Consider increasing impressions_queue_size") end end def add_bulk(key, treatments, time) treatments.each do |split_name, treatment| add(split_name, 'key_name' => key, 'treatment' => treatment, 'time' => time) end end # Get everything from the queue and leave it empty def clear @adapter.clear end private def random_sampler @random_sampler ||= Random.new end end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems