Class: SplitIoClient::Telemetry::MemoryRuntimeConsumer

Inherits:
Object
  • Object
show all
Defined in:
lib/splitclient-rb/telemetry/memory/memory_runtime_consumer.rb

Constant Summary collapse

DEFAULT_VALUE =
0

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ MemoryRuntimeConsumer

Returns a new instance of MemoryRuntimeConsumer.



8
9
10
11
# File 'lib/splitclient-rb/telemetry/memory/memory_runtime_consumer.rb', line 8

def initialize(config)
  @config = config
  @adapter = config.telemetry_adapter
end

Instance Method Details

#events_stats(type) ⇒ Object



25
26
27
# File 'lib/splitclient-rb/telemetry/memory/memory_runtime_consumer.rb', line 25

def events_stats(type)
  @adapter.events_data_records.find { |l| l[:type] == type }[:value].value
end

#impressions_stats(type) ⇒ Object



21
22
23
# File 'lib/splitclient-rb/telemetry/memory/memory_runtime_consumer.rb', line 21

def impressions_stats(type)
  @adapter.impressions_data_records.find { |l| l[:type] == type }[:value].value
end

#last_synchronizationsObject



29
30
31
32
33
34
35
36
37
38
39
# File 'lib/splitclient-rb/telemetry/memory/memory_runtime_consumer.rb', line 29

def last_synchronizations
  splits = find_last_synchronization(Domain::Constants::SPLIT_SYNC)
  segments = find_last_synchronization(Domain::Constants::SEGMENT_SYNC)
  impressions = find_last_synchronization(Domain::Constants::IMPRESSIONS_SYNC)
  imp_count = find_last_synchronization(Domain::Constants::IMPRESSION_COUNT_SYNC)
  events = find_last_synchronization(Domain::Constants::EVENT_SYNC)
  telemetry = find_last_synchronization(Domain::Constants::TELEMETRY_SYNC)
  token = find_last_synchronization(Domain::Constants::TOKEN_SYNC)

  LastSynchronization.new(splits, segments, impressions, imp_count, events, telemetry, token)
end

#pop_auth_rejectionsObject



69
70
71
72
73
74
75
# File 'lib/splitclient-rb/telemetry/memory/memory_runtime_consumer.rb', line 69

def pop_auth_rejections
  to_return = @adapter.auth_rejections

  @adapter.init_auth_rejections

  to_return.value
end

#pop_http_errorsObject



41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/splitclient-rb/telemetry/memory/memory_runtime_consumer.rb', line 41

def pop_http_errors
  splits = find_http_errors(Domain::Constants::SPLIT_SYNC)
  segments = find_http_errors(Domain::Constants::SEGMENT_SYNC)
  impressions = find_http_errors(Domain::Constants::IMPRESSIONS_SYNC)
  imp_count = find_http_errors(Domain::Constants::IMPRESSION_COUNT_SYNC)
  events = find_http_errors(Domain::Constants::EVENT_SYNC)
  telemetry = find_http_errors(Domain::Constants::TELEMETRY_SYNC)
  token = find_http_errors(Domain::Constants::TOKEN_SYNC)

  @adapter.init_http_errors

  HttpErrors.new(splits, segments, impressions, imp_count, events, telemetry, token)
end

#pop_http_latenciesObject



55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/splitclient-rb/telemetry/memory/memory_runtime_consumer.rb', line 55

def pop_http_latencies
  splits = find_http_latencies(Domain::Constants::SPLIT_SYNC)
  segments = find_http_latencies(Domain::Constants::SEGMENT_SYNC)
  impressions = find_http_latencies(Domain::Constants::IMPRESSIONS_SYNC)
  imp_count = find_http_latencies(Domain::Constants::IMPRESSION_COUNT_SYNC)
  events = find_http_latencies(Domain::Constants::EVENT_SYNC)
  telemetry = find_http_latencies(Domain::Constants::TELEMETRY_SYNC)
  token = find_http_latencies(Domain::Constants::TOKEN_SYNC)

  @adapter.init_http_latencies

  HttpLatencies.new(splits, segments, impressions, imp_count, events, telemetry, token)
end

#pop_streaming_eventsObject



85
86
87
88
89
90
91
# File 'lib/splitclient-rb/telemetry/memory/memory_runtime_consumer.rb', line 85

def pop_streaming_events
  events = @adapter.streaming_events

  @adapter.init_streaming_events.map

  events
end

#pop_tagsObject



13
14
15
16
17
18
19
# File 'lib/splitclient-rb/telemetry/memory/memory_runtime_consumer.rb', line 13

def pop_tags
  to_return = @adapter.tags

  @adapter.init_tags

  to_return
end

#pop_token_refreshesObject



77
78
79
80
81
82
83
# File 'lib/splitclient-rb/telemetry/memory/memory_runtime_consumer.rb', line 77

def pop_token_refreshes
  to_return = @adapter.token_refreshes

  @adapter.init_token_refreshes

  to_return.value
end

#pop_updates_from_sseObject



97
98
99
100
101
102
# File 'lib/splitclient-rb/telemetry/memory/memory_runtime_consumer.rb', line 97

def pop_updates_from_sse
  splits = @adapter.updates_from_sse[Domain::Constants::SPLITS]
  @adapter.updates_from_sse[Domain::Constants::SPLITS] = 0

  UpdatesFromSSE.new(splits)
end

#session_lengthObject



93
94
95
# File 'lib/splitclient-rb/telemetry/memory/memory_runtime_consumer.rb', line 93

def session_length
  @adapter.session_length.value
end