Sha256: d1afb3d171b1978baec8d496faeb53bcb5ad738f32a5e4f251d98347a4df6910
Contents?: true
Size: 1.49 KB
Versions: 20
Compression:
Stored size: 1.49 KB
Contents
# frozen_string_literal: true module SplitIoClient module Cache module Repositories # Repository which forwards impressions interface to the selected adapter class ImpressionsRepository < Repository extend Forwardable def_delegators :@adapter, :add, :add_bulk, :batch, :empty? def initialize(adapter) @adapter = case adapter.class.to_s when 'SplitIoClient::Cache::Adapters::MemoryAdapter' Repositories::Impressions::MemoryRepository.new(adapter) when 'SplitIoClient::Cache::Adapters::RedisAdapter' Repositories::Impressions::RedisRepository.new(adapter) end end protected def impression_data(matching_key, bucketing_key, split_name, treatment, timestamp) { k: matching_key, b: bucketing_key, f: split_name, t: treatment[:treatment], r: applied_rule(treatment[:label]), c: treatment[:change_number], m: timestamp } end def metadata { s: "#{SplitIoClient.configuration.language}-#{SplitIoClient.configuration.version}", i: SplitIoClient.configuration.machine_ip, n: SplitIoClient.configuration.machine_name } end def applied_rule(label) SplitIoClient.configuration.labels_enabled ? label : nil end end end end end
Version data entries
20 entries across 20 versions & 1 rubygems