Class: MetricsProcessor::FrequencyMap

Inherits:
Concurrent::Map
  • Object
show all
Defined in:
lib/ff/ruby/server/sdk/api/metrics_processor.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = nil, &block) ⇒ FrequencyMap

Returns a new instance of FrequencyMap.



14
15
16
# File 'lib/ff/ruby/server/sdk/api/metrics_processor.rb', line 14

def initialize(options = nil, &block)
  super
end

Instance Method Details

#drain_to_mapObject



32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/ff/ruby/server/sdk/api/metrics_processor.rb', line 32

def drain_to_map
  result = {}
  each_key do |key|
    result[key] = 0
  end
  result.each_key do |key|
    value = get_and_set(key, 0)
    result[key] = value
    delete_pair(key, 0)
  end
  result
end

#get(key) ⇒ Object



28
29
30
# File 'lib/ff/ruby/server/sdk/api/metrics_processor.rb', line 28

def get(key)
  self[key]
end

#increment(key) ⇒ Object



18
19
20
21
22
23
24
25
26
# File 'lib/ff/ruby/server/sdk/api/metrics_processor.rb', line 18

def increment(key)
  compute(key) do |old_value|
    if old_value == nil;
      1
    else
      old_value + 1
    end
  end
end