splitclient-rb 7.2.2-java → 7.3.0.pre.rc1-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +15 -0
- data/CHANGES.txt +6 -0
- data/lib/splitclient-rb.rb +24 -9
- data/lib/splitclient-rb/cache/adapters/redis_adapter.rb +4 -0
- data/lib/splitclient-rb/cache/fetchers/segment_fetcher.rb +16 -7
- data/lib/splitclient-rb/cache/fetchers/split_fetcher.rb +9 -9
- data/lib/splitclient-rb/cache/repositories/events/memory_repository.rb +6 -3
- data/lib/splitclient-rb/cache/repositories/events_repository.rb +4 -3
- data/lib/splitclient-rb/cache/repositories/impressions/memory_repository.rb +8 -0
- data/lib/splitclient-rb/cache/repositories/impressions/redis_repository.rb +2 -0
- data/lib/splitclient-rb/cache/repositories/repository.rb +0 -4
- data/lib/splitclient-rb/cache/repositories/segments_repository.rb +20 -0
- data/lib/splitclient-rb/cache/repositories/splits_repository.rb +4 -0
- data/lib/splitclient-rb/cache/senders/localhost_repo_cleaner.rb +1 -3
- data/lib/splitclient-rb/cache/stores/sdk_blocker.rb +9 -0
- data/lib/splitclient-rb/clients/split_client.rb +59 -25
- data/lib/splitclient-rb/constants.rb +6 -1
- data/lib/splitclient-rb/engine/api/client.rb +3 -2
- data/lib/splitclient-rb/engine/api/events.rb +10 -1
- data/lib/splitclient-rb/engine/api/impressions.rb +19 -2
- data/lib/splitclient-rb/engine/api/segments.rb +20 -18
- data/lib/splitclient-rb/engine/api/splits.rb +10 -10
- data/lib/splitclient-rb/engine/api/telemetry_api.rb +39 -0
- data/lib/splitclient-rb/engine/auth_api_client.rb +21 -8
- data/lib/splitclient-rb/engine/common/impressions_manager.rb +27 -3
- data/lib/splitclient-rb/engine/metrics/binary_search_latency_tracker.rb +3 -65
- data/lib/splitclient-rb/engine/push_manager.rb +12 -3
- data/lib/splitclient-rb/engine/sync_manager.rb +85 -46
- data/lib/splitclient-rb/engine/synchronizer.rb +14 -22
- data/lib/splitclient-rb/split_config.rb +46 -21
- data/lib/splitclient-rb/split_factory.rb +31 -13
- data/lib/splitclient-rb/split_factory_registry.rb +12 -0
- data/lib/splitclient-rb/sse/event_source/client.rb +53 -28
- data/lib/splitclient-rb/sse/event_source/event_parser.rb +10 -1
- data/lib/splitclient-rb/sse/notification_manager_keeper.rb +45 -26
- data/lib/splitclient-rb/sse/sse_handler.rb +16 -21
- data/lib/splitclient-rb/sse/workers/segments_worker.rb +5 -4
- data/lib/splitclient-rb/sse/workers/splits_worker.rb +6 -3
- data/lib/splitclient-rb/telemetry/domain/constants.rb +42 -0
- data/lib/splitclient-rb/telemetry/domain/structs.rb +31 -0
- data/lib/splitclient-rb/telemetry/evaluation_consumer.rb +14 -0
- data/lib/splitclient-rb/telemetry/evaluation_producer.rb +21 -0
- data/lib/splitclient-rb/telemetry/init_consumer.rb +14 -0
- data/lib/splitclient-rb/telemetry/init_producer.rb +19 -0
- data/lib/splitclient-rb/telemetry/memory/memory_evaluation_consumer.rb +32 -0
- data/lib/splitclient-rb/telemetry/memory/memory_evaluation_producer.rb +24 -0
- data/lib/splitclient-rb/telemetry/memory/memory_init_consumer.rb +28 -0
- data/lib/splitclient-rb/telemetry/memory/memory_init_producer.rb +34 -0
- data/lib/splitclient-rb/telemetry/memory/memory_runtime_consumer.rb +112 -0
- data/lib/splitclient-rb/telemetry/memory/memory_runtime_producer.rb +81 -0
- data/lib/splitclient-rb/telemetry/memory/memory_synchronizer.rb +192 -0
- data/lib/splitclient-rb/telemetry/redis/redis_evaluation_producer.rb +38 -0
- data/lib/splitclient-rb/telemetry/redis/redis_init_producer.rb +37 -0
- data/lib/splitclient-rb/telemetry/redis/redis_synchronizer.rb +28 -0
- data/lib/splitclient-rb/telemetry/runtime_consumer.rb +24 -0
- data/lib/splitclient-rb/telemetry/runtime_producer.rb +24 -0
- data/lib/splitclient-rb/telemetry/storages/memory.rb +139 -0
- data/lib/splitclient-rb/telemetry/sync_task.rb +38 -0
- data/lib/splitclient-rb/telemetry/synchronizer.rb +29 -0
- data/lib/splitclient-rb/version.rb +1 -1
- metadata +26 -11
- data/lib/splitclient-rb/cache/repositories/metrics/memory_repository.rb +0 -163
- data/lib/splitclient-rb/cache/repositories/metrics/redis_repository.rb +0 -131
- data/lib/splitclient-rb/cache/repositories/metrics_repository.rb +0 -23
- data/lib/splitclient-rb/cache/senders/metrics_sender.rb +0 -55
- data/lib/splitclient-rb/engine/api/metrics.rb +0 -61
- data/lib/splitclient-rb/engine/metrics/metrics.rb +0 -80
- data/lib/splitclient-rb/redis_metrics_fixer.rb +0 -36
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cf76aeaf59be33d7721f2d75ba0d85f93195d6fb
|
4
|
+
data.tar.gz: 94a402249888d23745fa76bccceb20fbe41f696e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4e72626d013ea7f9d5f082fd92254bc56e040ff05798545d9acd9cb9b2c9b6fd80f1b9b397fdd12c0dcdcd6a686f78aaad31fb228de6d690f333d6ee4f8b5ea5
|
7
|
+
data.tar.gz: 45a78ddf9d5529854ed970494a8fba631378dfd7105af8fa7287e4ced427b749a325696faef1594fd6bfc2003e4c12ffe16e79de8726cfcf52a1e4f047fe5c56
|
data/.rubocop.yml
CHANGED
@@ -3,12 +3,25 @@ Documentation:
|
|
3
3
|
|
4
4
|
Metrics/AbcSize:
|
5
5
|
Max: 26
|
6
|
+
Exclude:
|
7
|
+
- lib/splitclient-rb/telemetry/memory/memory_synchronizer.rb
|
6
8
|
|
7
9
|
Metrics/MethodLength:
|
8
10
|
Max: 20
|
11
|
+
Exclude:
|
12
|
+
- lib/splitclient-rb/telemetry/memory/memory_synchronizer.rb
|
9
13
|
|
10
14
|
Metrics/ClassLength:
|
11
15
|
Max: 150
|
16
|
+
Exclude:
|
17
|
+
- lib/splitclient-rb/telemetry/memory/memory_synchronizer.rb
|
18
|
+
|
19
|
+
Metrics/CyclomaticComplexity:
|
20
|
+
Max: 8
|
21
|
+
|
22
|
+
Metrics/ParameterLists:
|
23
|
+
Exclude:
|
24
|
+
- lib/splitclient-rb/engine/sync_manager.rb
|
12
25
|
|
13
26
|
Metrics/LineLength:
|
14
27
|
Max: 130
|
@@ -17,6 +30,7 @@ Metrics/LineLength:
|
|
17
30
|
- spec/integrations/**/*
|
18
31
|
- spec/engine/sync_manager_spec.rb
|
19
32
|
- spec/engine/auth_api_client_spec.rb
|
33
|
+
- spec/telemetry/synchronizer_spec.rb
|
20
34
|
|
21
35
|
Style/BracesAroundHashParameters:
|
22
36
|
Exclude:
|
@@ -47,3 +61,4 @@ AllCops:
|
|
47
61
|
- lib/splitclient-rb/engine/metrics/**/*
|
48
62
|
- lib/splitclient-rb/engine/models/**/*
|
49
63
|
- lib/splitclient-rb/engine/parser/**/*
|
64
|
+
- spec/telemetry/synchronizer_spec.rb
|
data/CHANGES.txt
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
CHANGES
|
2
2
|
|
3
|
+
7.2.3 (Feb 24, 2021)
|
4
|
+
- Fixed missing segment fetch after an SPLIT_UPDATE.
|
5
|
+
- Updated streaming logic to support multiregion.
|
6
|
+
- Updated sse client connection logic to read confirmation event.
|
7
|
+
- Updated naming of retryable erros.
|
8
|
+
|
3
9
|
7.2.2 (Dec 18, 2020)
|
4
10
|
- Fixed issue: undefined local variable or method post_impressions_count
|
5
11
|
|
data/lib/splitclient-rb.rb
CHANGED
@@ -23,12 +23,8 @@ require 'splitclient-rb/cache/repositories/events/memory_repository'
|
|
23
23
|
require 'splitclient-rb/cache/repositories/events/redis_repository'
|
24
24
|
require 'splitclient-rb/cache/repositories/impressions/memory_repository'
|
25
25
|
require 'splitclient-rb/cache/repositories/impressions/redis_repository'
|
26
|
-
require 'splitclient-rb/cache/repositories/metrics_repository'
|
27
|
-
require 'splitclient-rb/cache/repositories/metrics/memory_repository'
|
28
|
-
require 'splitclient-rb/cache/repositories/metrics/redis_repository'
|
29
26
|
require 'splitclient-rb/cache/senders/impressions_formatter'
|
30
27
|
require 'splitclient-rb/cache/senders/impressions_sender'
|
31
|
-
require 'splitclient-rb/cache/senders/metrics_sender'
|
32
28
|
require 'splitclient-rb/cache/senders/events_sender'
|
33
29
|
require 'splitclient-rb/cache/senders/impressions_count_sender'
|
34
30
|
require 'splitclient-rb/cache/senders/localhost_repo_cleaner'
|
@@ -51,10 +47,10 @@ require 'splitclient-rb/engine/api/faraday_middleware/gzip'
|
|
51
47
|
require 'splitclient-rb/engine/api/faraday_adapter/patched_net_http_persistent'
|
52
48
|
require 'splitclient-rb/engine/api/client'
|
53
49
|
require 'splitclient-rb/engine/api/impressions'
|
54
|
-
require 'splitclient-rb/engine/api/metrics'
|
55
50
|
require 'splitclient-rb/engine/api/segments'
|
56
51
|
require 'splitclient-rb/engine/api/splits'
|
57
52
|
require 'splitclient-rb/engine/api/events'
|
53
|
+
require 'splitclient-rb/engine/api/telemetry_api'
|
58
54
|
require 'splitclient-rb/engine/common/impressions_counter'
|
59
55
|
require 'splitclient-rb/engine/common/impressions_manager'
|
60
56
|
require 'splitclient-rb/engine/parser/condition'
|
@@ -84,7 +80,6 @@ require 'splitclient-rb/engine/matchers/equal_to_boolean_matcher'
|
|
84
80
|
require 'splitclient-rb/engine/matchers/equal_to_matcher'
|
85
81
|
require 'splitclient-rb/engine/matchers/matches_string_matcher'
|
86
82
|
require 'splitclient-rb/engine/evaluator/splitter'
|
87
|
-
require 'splitclient-rb/engine/metrics/metrics'
|
88
83
|
require 'splitclient-rb/engine/metrics/binary_search_latency_tracker'
|
89
84
|
require 'splitclient-rb/engine/models/split'
|
90
85
|
require 'splitclient-rb/engine/models/label'
|
@@ -95,9 +90,6 @@ require 'splitclient-rb/engine/sync_manager'
|
|
95
90
|
require 'splitclient-rb/engine/synchronizer'
|
96
91
|
require 'splitclient-rb/utilitites'
|
97
92
|
|
98
|
-
# redis metrics fixer
|
99
|
-
require 'splitclient-rb/redis_metrics_fixer'
|
100
|
-
|
101
93
|
# SSE
|
102
94
|
require 'splitclient-rb/sse/event_source/back_off'
|
103
95
|
require 'splitclient-rb/sse/event_source/client'
|
@@ -110,6 +102,29 @@ require 'splitclient-rb/sse/notification_manager_keeper'
|
|
110
102
|
require 'splitclient-rb/sse/notification_processor'
|
111
103
|
require 'splitclient-rb/sse/sse_handler'
|
112
104
|
|
105
|
+
# Telemetry
|
106
|
+
require 'splitclient-rb/telemetry/domain/constants'
|
107
|
+
require 'splitclient-rb/telemetry/domain/structs'
|
108
|
+
require 'splitclient-rb/telemetry/storages/memory'
|
109
|
+
require 'splitclient-rb/telemetry/evaluation_consumer'
|
110
|
+
require 'splitclient-rb/telemetry/evaluation_producer'
|
111
|
+
require 'splitclient-rb/telemetry/init_consumer'
|
112
|
+
require 'splitclient-rb/telemetry/init_producer'
|
113
|
+
require 'splitclient-rb/telemetry/runtime_consumer'
|
114
|
+
require 'splitclient-rb/telemetry/runtime_producer'
|
115
|
+
require 'splitclient-rb/telemetry/sync_task'
|
116
|
+
require 'splitclient-rb/telemetry/synchronizer'
|
117
|
+
require 'splitclient-rb/telemetry/memory/memory_evaluation_consumer'
|
118
|
+
require 'splitclient-rb/telemetry/memory/memory_evaluation_producer'
|
119
|
+
require 'splitclient-rb/telemetry/memory/memory_init_consumer'
|
120
|
+
require 'splitclient-rb/telemetry/memory/memory_init_producer'
|
121
|
+
require 'splitclient-rb/telemetry/memory/memory_runtime_consumer'
|
122
|
+
require 'splitclient-rb/telemetry/memory/memory_runtime_producer'
|
123
|
+
require 'splitclient-rb/telemetry/memory/memory_synchronizer'
|
124
|
+
require 'splitclient-rb/telemetry/redis/redis_evaluation_producer'
|
125
|
+
require 'splitclient-rb/telemetry/redis/redis_init_producer'
|
126
|
+
require 'splitclient-rb/telemetry/redis/redis_synchronizer'
|
127
|
+
|
113
128
|
# C extension
|
114
129
|
require 'murmurhash/murmurhash_mri'
|
115
130
|
|
@@ -4,13 +4,13 @@ module SplitIoClient
|
|
4
4
|
class SegmentFetcher
|
5
5
|
attr_reader :segments_repository
|
6
6
|
|
7
|
-
def initialize(segments_repository, api_key,
|
7
|
+
def initialize(segments_repository, api_key, config, sdk_blocker, telemetry_runtime_producer)
|
8
8
|
@segments_repository = segments_repository
|
9
9
|
@api_key = api_key
|
10
|
-
@metrics = metrics
|
11
10
|
@config = config
|
12
11
|
@sdk_blocker = sdk_blocker
|
13
12
|
@semaphore = Mutex.new
|
13
|
+
@telemetry_runtime_producer = telemetry_runtime_producer
|
14
14
|
end
|
15
15
|
|
16
16
|
def call
|
@@ -27,14 +27,22 @@ module SplitIoClient
|
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
-
def
|
30
|
+
def fetch_segments_if_not_exists(names, cache_control_headers = false)
|
31
|
+
names.each do |name|
|
32
|
+
change_number = @segments_repository.get_change_number(name)
|
33
|
+
|
34
|
+
fetch_segment(name, cache_control_headers) if change_number == -1
|
35
|
+
end
|
36
|
+
rescue StandardError => error
|
37
|
+
@config.log_found_exception(__method__.to_s, error)
|
38
|
+
end
|
39
|
+
|
40
|
+
def fetch_segment(name, cache_control_headers = false)
|
31
41
|
@semaphore.synchronize do
|
32
|
-
segments_api.fetch_segments_by_names([name])
|
33
|
-
true
|
42
|
+
segments_api.fetch_segments_by_names([name], cache_control_headers)
|
34
43
|
end
|
35
44
|
rescue StandardError => error
|
36
45
|
@config.log_found_exception(__method__.to_s, error)
|
37
|
-
false
|
38
46
|
end
|
39
47
|
|
40
48
|
def fetch_segments
|
@@ -42,6 +50,7 @@ module SplitIoClient
|
|
42
50
|
segments_api.fetch_segments_by_names(@segments_repository.used_segment_names)
|
43
51
|
|
44
52
|
@sdk_blocker.segments_ready!
|
53
|
+
@sdk_blocker.sdk_internal_ready
|
45
54
|
end
|
46
55
|
rescue StandardError => error
|
47
56
|
@config.log_found_exception(__method__.to_s, error)
|
@@ -71,7 +80,7 @@ module SplitIoClient
|
|
71
80
|
end
|
72
81
|
|
73
82
|
def segments_api
|
74
|
-
@segments_api ||= SplitIoClient::Api::Segments.new(@api_key, @
|
83
|
+
@segments_api ||= SplitIoClient::Api::Segments.new(@api_key, @segments_repository, @config, @telemetry_runtime_producer)
|
75
84
|
end
|
76
85
|
end
|
77
86
|
end
|
@@ -4,13 +4,13 @@ module SplitIoClient
|
|
4
4
|
class SplitFetcher
|
5
5
|
attr_reader :splits_repository
|
6
6
|
|
7
|
-
def initialize(splits_repository, api_key,
|
7
|
+
def initialize(splits_repository, api_key, config, sdk_blocker, telemetry_runtime_producer)
|
8
8
|
@splits_repository = splits_repository
|
9
9
|
@api_key = api_key
|
10
|
-
@metrics = metrics
|
11
10
|
@config = config
|
12
11
|
@sdk_blocker = sdk_blocker
|
13
12
|
@semaphore = Mutex.new
|
13
|
+
@telemetry_runtime_producer = telemetry_runtime_producer
|
14
14
|
end
|
15
15
|
|
16
16
|
def call
|
@@ -27,9 +27,9 @@ module SplitIoClient
|
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
-
def fetch_splits
|
30
|
+
def fetch_splits(cache_control_headers = false)
|
31
31
|
@semaphore.synchronize do
|
32
|
-
data = splits_since(@splits_repository.get_change_number)
|
32
|
+
data = splits_since(@splits_repository.get_change_number, cache_control_headers)
|
33
33
|
|
34
34
|
data[:splits] && data[:splits].each do |split|
|
35
35
|
add_split_unless_archived(split)
|
@@ -41,11 +41,11 @@ module SplitIoClient
|
|
41
41
|
@config.logger.debug("segments seen(#{data[:segment_names].length}): #{data[:segment_names].to_a}") if @config.debug_enabled
|
42
42
|
|
43
43
|
@sdk_blocker.splits_ready!
|
44
|
-
|
44
|
+
|
45
|
+
data[:segment_names]
|
45
46
|
end
|
46
47
|
rescue StandardError => error
|
47
48
|
@config.log_found_exception(__method__.to_s, error)
|
48
|
-
false
|
49
49
|
end
|
50
50
|
|
51
51
|
def stop_splits_thread
|
@@ -67,8 +67,8 @@ module SplitIoClient
|
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
70
|
-
def splits_since(since)
|
71
|
-
splits_api.since(since)
|
70
|
+
def splits_since(since, cache_control_headers = false)
|
71
|
+
splits_api.since(since, cache_control_headers)
|
72
72
|
end
|
73
73
|
|
74
74
|
def add_split_unless_archived(split)
|
@@ -94,7 +94,7 @@ module SplitIoClient
|
|
94
94
|
end
|
95
95
|
|
96
96
|
def splits_api
|
97
|
-
@splits_api ||= SplitIoClient::Api::Splits.new(@api_key, @
|
97
|
+
@splits_api ||= SplitIoClient::Api::Splits.new(@api_key, @config, @telemetry_runtime_producer)
|
98
98
|
end
|
99
99
|
end
|
100
100
|
end
|
@@ -5,10 +5,11 @@ module SplitIoClient
|
|
5
5
|
class MemoryRepository < EventsRepository
|
6
6
|
EVENTS_MAX_SIZE_BYTES = 5242880
|
7
7
|
|
8
|
-
def initialize(config)
|
8
|
+
def initialize(config, telemetry_runtime_producer)
|
9
9
|
@config = config
|
10
10
|
@adapter = @config.events_adapter
|
11
11
|
@size = 0
|
12
|
+
@telemetry_runtime_producer = telemetry_runtime_producer
|
12
13
|
end
|
13
14
|
|
14
15
|
def add(key, traffic_type, event_type, time, value, properties, event_size)
|
@@ -17,8 +18,10 @@ module SplitIoClient
|
|
17
18
|
|
18
19
|
post_events if @size >= EVENTS_MAX_SIZE_BYTES || @adapter.length == @config.events_queue_size
|
19
20
|
|
20
|
-
|
21
|
-
|
21
|
+
@telemetry_runtime_producer.record_events_stats(Telemetry::Domain::Constants::EVENTS_QUEUED, 1)
|
22
|
+
rescue StandardError => error
|
23
|
+
@config.log_found_exception(__method__.to_s, error)
|
24
|
+
@telemetry_runtime_producer.record_events_stats(Telemetry::Domain::Constants::EVENTS_DROPPED, 1)
|
22
25
|
end
|
23
26
|
|
24
27
|
def clear
|
@@ -6,16 +6,17 @@ module SplitIoClient
|
|
6
6
|
extend Forwardable
|
7
7
|
def_delegators :@repository, :add, :clear, :batch
|
8
8
|
|
9
|
-
def initialize(config, api_key)
|
9
|
+
def initialize(config, api_key, telemetry_runtime_producer)
|
10
10
|
super(config)
|
11
11
|
@repository = case @config.events_adapter.class.to_s
|
12
12
|
when 'SplitIoClient::Cache::Adapters::MemoryAdapter'
|
13
|
-
Repositories::Events::MemoryRepository.new(@config)
|
13
|
+
Repositories::Events::MemoryRepository.new(@config, telemetry_runtime_producer)
|
14
14
|
when 'SplitIoClient::Cache::Adapters::RedisAdapter'
|
15
15
|
Repositories::Events::RedisRepository.new(@config)
|
16
16
|
end
|
17
17
|
|
18
18
|
@api_key = api_key
|
19
|
+
@telemetry_runtime_producer = telemetry_runtime_producer
|
19
20
|
end
|
20
21
|
|
21
22
|
def post_events
|
@@ -48,7 +49,7 @@ module SplitIoClient
|
|
48
49
|
private
|
49
50
|
|
50
51
|
def events_api
|
51
|
-
@events_api ||= SplitIoClient::Api::Events.new(@api_key, @config)
|
52
|
+
@events_api ||= SplitIoClient::Api::Events.new(@api_key, @config, @telemetry_runtime_producer)
|
52
53
|
end
|
53
54
|
end
|
54
55
|
end
|
@@ -11,15 +11,23 @@ module SplitIoClient
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def add_bulk(impressions)
|
14
|
+
return 0 if impressions.nil?
|
15
|
+
|
16
|
+
count = 0
|
14
17
|
impressions.each do |impression|
|
15
18
|
@adapter.add_to_queue(impression)
|
19
|
+
count += 1
|
16
20
|
end
|
21
|
+
|
22
|
+
0
|
17
23
|
rescue ThreadError # queue is full
|
18
24
|
if random_sampler.rand(1..1000) <= 2 # log only 0.2 % of the time
|
19
25
|
@config.logger.warn("Dropping impressions. Current size is \
|
20
26
|
#{@config.impressions_queue_size}. " \
|
21
27
|
'Consider increasing impressions_queue_size')
|
22
28
|
end
|
29
|
+
|
30
|
+
impressions.length - count
|
23
31
|
end
|
24
32
|
|
25
33
|
def batch
|
@@ -21,8 +21,10 @@ module SplitIoClient
|
|
21
21
|
|
22
22
|
# Synchronizer might not be running
|
23
23
|
@adapter.expire(key, EXPIRE_SECONDS) if impressions_json.size == impressions_list_size
|
24
|
+
0
|
24
25
|
rescue StandardError => e
|
25
26
|
@config.logger.error("Exception while add_bulk: #{e}")
|
27
|
+
0
|
26
28
|
end
|
27
29
|
|
28
30
|
def get_impressions(number_of_impressions = 0)
|
@@ -63,6 +63,26 @@ module SplitIoClient
|
|
63
63
|
@adapter.clear(namespace_key)
|
64
64
|
end
|
65
65
|
|
66
|
+
def segments_count
|
67
|
+
used_segment_names.length
|
68
|
+
end
|
69
|
+
|
70
|
+
def segment_keys_count
|
71
|
+
names = used_segment_names
|
72
|
+
|
73
|
+
keys = 0
|
74
|
+
|
75
|
+
names.each do |name|
|
76
|
+
segment_keys = get_segment_keys(name)
|
77
|
+
keys += segment_keys.length
|
78
|
+
end
|
79
|
+
|
80
|
+
keys
|
81
|
+
rescue StandardError => error
|
82
|
+
@config.log_found_exception(__method__.to_s, error)
|
83
|
+
0
|
84
|
+
end
|
85
|
+
|
66
86
|
private
|
67
87
|
|
68
88
|
def segment_data(name)
|
@@ -4,9 +4,8 @@ module SplitIoClient
|
|
4
4
|
module Cache
|
5
5
|
module Senders
|
6
6
|
class LocalhostRepoCleaner
|
7
|
-
def initialize(impressions_repository,
|
7
|
+
def initialize(impressions_repository, events_repository, config)
|
8
8
|
@impressions_repository = impressions_repository
|
9
|
-
@metrics_repository = metrics_repository
|
10
9
|
@events_repository = events_repository
|
11
10
|
@config = config
|
12
11
|
end
|
@@ -40,7 +39,6 @@ module SplitIoClient
|
|
40
39
|
|
41
40
|
def clear_repositories
|
42
41
|
@impressions_repository.clear
|
43
|
-
@metrics_repository.clear
|
44
42
|
@events_repository.clear
|
45
43
|
end
|
46
44
|
end
|
@@ -11,6 +11,7 @@ module SplitIoClient
|
|
11
11
|
@splits_repository = splits_repository
|
12
12
|
@segments_repository = segments_repository
|
13
13
|
@config = config
|
14
|
+
@internal_ready = Concurrent::CountDownLatch.new(1)
|
14
15
|
|
15
16
|
if @config.standalone?
|
16
17
|
@splits_repository.not_ready!
|
@@ -49,6 +50,14 @@ module SplitIoClient
|
|
49
50
|
return true if @config.consumer?
|
50
51
|
@splits_repository.ready? && @segments_repository.ready?
|
51
52
|
end
|
53
|
+
|
54
|
+
def sdk_internal_ready
|
55
|
+
@internal_ready.count_down
|
56
|
+
end
|
57
|
+
|
58
|
+
def wait_unitil_internal_ready
|
59
|
+
@internal_ready.wait
|
60
|
+
end
|
52
61
|
end
|
53
62
|
end
|
54
63
|
end
|