splitclient-rb 8.10.1.pre.rc1-java → 8.11.0-java
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGES.txt +10 -1
- data/LICENSE +169 -13
- data/NOTICE.txt +5 -0
- data/lib/splitclient-rb/cache/repositories/rule_based_segments_repository.rb +14 -1
- data/lib/splitclient-rb/cache/repositories/segments_repository.rb +13 -2
- data/lib/splitclient-rb/cache/repositories/splits_repository.rb +23 -1
- data/lib/splitclient-rb/clients/split_client.rb +12 -3
- data/lib/splitclient-rb/engine/api/faraday_middleware/gzip.rb +1 -0
- data/lib/splitclient-rb/engine/api/splits.rb +2 -2
- data/lib/splitclient-rb/engine/auth_api_client.rb +7 -3
- data/lib/splitclient-rb/engine/events/events_delivery.rb +20 -0
- data/lib/splitclient-rb/engine/events/events_manager.rb +194 -0
- data/lib/splitclient-rb/engine/events/events_manager_config.rb +96 -0
- data/lib/splitclient-rb/engine/events/events_task.rb +50 -0
- data/lib/splitclient-rb/engine/events/noop_events_queue.rb +13 -0
- data/lib/splitclient-rb/engine/matchers/rule_based_segment_matcher.rb +7 -4
- data/lib/splitclient-rb/engine/models/event_active_subscriptions.rb +14 -0
- data/lib/splitclient-rb/engine/models/events_metadata.rb +10 -0
- data/lib/splitclient-rb/engine/models/sdk_event.rb +4 -0
- data/lib/splitclient-rb/engine/models/sdk_event_type.rb +4 -0
- data/lib/splitclient-rb/engine/models/sdk_internal_event.rb +8 -0
- data/lib/splitclient-rb/engine/models/sdk_internal_event_notification.rb +16 -0
- data/lib/splitclient-rb/engine/models/valid_sdk_event.rb +14 -0
- data/lib/splitclient-rb/engine/status_manager.rb +7 -1
- data/lib/splitclient-rb/engine/sync_manager.rb +10 -6
- data/lib/splitclient-rb/split_factory.rb +20 -5
- data/lib/splitclient-rb/sse/event_source/client.rb +14 -15
- data/lib/splitclient-rb/sse/event_source/event_parser.rb +2 -2
- data/lib/splitclient-rb/sse/notification_manager_keeper.rb +3 -3
- data/lib/splitclient-rb/sse/workers/segments_worker.rb +4 -4
- data/lib/splitclient-rb/sse/workers/splits_worker.rb +9 -5
- data/lib/splitclient-rb/version.rb +1 -1
- data/lib/splitclient-rb.rb +12 -0
- metadata +15 -2
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module SplitIoClient
|
|
4
|
+
module Engine
|
|
5
|
+
module Events
|
|
6
|
+
class EventsManagerConfig
|
|
7
|
+
attr_accessor :require_all, :prerequisites, :require_any, :suppressed_by, :execution_limits, :evaluation_order
|
|
8
|
+
|
|
9
|
+
def initialize
|
|
10
|
+
@require_all = construct_require_all
|
|
11
|
+
@prerequisites = construct_prerequisites
|
|
12
|
+
@require_any = construct_require_any
|
|
13
|
+
@suppressed_by = construct_suppressed_by
|
|
14
|
+
@execution_limits = construct_execution_limits
|
|
15
|
+
@evaluation_order = construct_sorted_events
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
private
|
|
19
|
+
|
|
20
|
+
def construct_require_all
|
|
21
|
+
{
|
|
22
|
+
SplitIoClient::Engine::Models::SdkEvent::SDK_READY => Set.new([SplitIoClient::Engine::Models::SdkInternalEvent::SDK_READY])
|
|
23
|
+
}
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def construct_prerequisites
|
|
27
|
+
{
|
|
28
|
+
SplitIoClient::Engine::Models::SdkEvent::SDK_UPDATE => Set.new([SplitIoClient::Engine::Models::SdkEvent::SDK_READY])
|
|
29
|
+
}
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def construct_require_any
|
|
33
|
+
{
|
|
34
|
+
SplitIoClient::Engine::Models::SdkEvent::SDK_UPDATE => Set.new(
|
|
35
|
+
[
|
|
36
|
+
SplitIoClient::Engine::Models::SdkInternalEvent::FLAG_KILLED_NOTIFICATION,
|
|
37
|
+
SplitIoClient::Engine::Models::SdkInternalEvent::FLAGS_UPDATED,
|
|
38
|
+
SplitIoClient::Engine::Models::SdkInternalEvent::RB_SEGMENTS_UPDATED,
|
|
39
|
+
SplitIoClient::Engine::Models::SdkInternalEvent::SEGMENTS_UPDATED
|
|
40
|
+
]
|
|
41
|
+
)
|
|
42
|
+
}
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def construct_suppressed_by
|
|
46
|
+
{}
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def construct_execution_limits
|
|
50
|
+
{
|
|
51
|
+
SplitIoClient::Engine::Models::SdkEvent::SDK_READY => 1,
|
|
52
|
+
SplitIoClient::Engine::Models::SdkEvent::SDK_UPDATE => -1
|
|
53
|
+
}
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def construct_sorted_events
|
|
57
|
+
sorted_events = []
|
|
58
|
+
[SplitIoClient::Engine::Models::SdkEvent::SDK_READY, SplitIoClient::Engine::Models::SdkEvent::SDK_UPDATE].each do |sdk_event|
|
|
59
|
+
sorted_events = dfs_recursive(sdk_event, sorted_events)
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
sorted_events
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def dfs_recursive(sdk_event, added)
|
|
66
|
+
return added if added.include?(sdk_event)
|
|
67
|
+
|
|
68
|
+
get_dependencies(sdk_event).each do |dependent_event|
|
|
69
|
+
added = dfs_recursive(dependent_event, added)
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
added.push(sdk_event)
|
|
73
|
+
|
|
74
|
+
added
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def get_dependencies(sdk_event)
|
|
78
|
+
dependencies = Set.new
|
|
79
|
+
@prerequisites.each do |prerequisites_event_name, prerequisites_event_value|
|
|
80
|
+
next unless prerequisites_event_name == sdk_event
|
|
81
|
+
|
|
82
|
+
prerequisites_event_value.each do |prereq_event|
|
|
83
|
+
dependencies.add(prereq_event)
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
@suppressed_by.each do |suppressed_event_name, suppressed_event_value|
|
|
88
|
+
dependencies.add(suppressed_event_name) if suppressed_event_value.include?(sdk_event)
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
dependencies
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
end
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module SplitIoClient
|
|
4
|
+
module Engine
|
|
5
|
+
module Events
|
|
6
|
+
class EventsTask
|
|
7
|
+
attr_accessor :running
|
|
8
|
+
|
|
9
|
+
def initialize(notify_internal_events, internal_events_queue, config)
|
|
10
|
+
@notify_internal_events = notify_internal_events
|
|
11
|
+
@internal_events_queue = internal_events_queue
|
|
12
|
+
@config = config
|
|
13
|
+
@running = false
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def start
|
|
17
|
+
return if @running
|
|
18
|
+
|
|
19
|
+
@config.logger.info('Starting Internal Events Task.')
|
|
20
|
+
@running = true
|
|
21
|
+
@config.threads[:internal_events_task] = Thread.new do
|
|
22
|
+
worker_thread
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def stop
|
|
27
|
+
return unless @running
|
|
28
|
+
|
|
29
|
+
@config.logger.info('Stopping Internal Events Task.')
|
|
30
|
+
@running = false
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
private
|
|
34
|
+
|
|
35
|
+
def worker_thread
|
|
36
|
+
while (event = @internal_events_queue.pop)
|
|
37
|
+
break unless @running
|
|
38
|
+
|
|
39
|
+
@config.logger.debug("Processing sdk internal event: #{event.internal_event}") if @config.debug_enabled
|
|
40
|
+
begin
|
|
41
|
+
@notify_internal_events.call(event.internal_event, event.metadata)
|
|
42
|
+
rescue StandardError => e
|
|
43
|
+
@config.log_found_exception(__method__.to_s, e)
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
@@ -30,15 +30,18 @@ module SplitIoClient
|
|
|
30
30
|
|
|
31
31
|
return false unless check_excluded_segments(rule_based_segment, key, args)
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
matched = false
|
|
34
34
|
rule_based_segment[:conditions].each do |c|
|
|
35
35
|
condition = SplitIoClient::Condition.new(c, @config)
|
|
36
36
|
next if condition.empty?
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
matched = Helpers::EvaluatorHelper.matcher_type(condition, @segments_repository, @rule_based_segments_repository).match?(args)
|
|
39
|
+
|
|
40
|
+
break if matched
|
|
39
41
|
end
|
|
40
|
-
|
|
41
|
-
|
|
42
|
+
|
|
43
|
+
@logger.debug("[InRuleSegmentMatcher] #{@segment_name} is in rule based segment -> #{matched}")
|
|
44
|
+
matched
|
|
42
45
|
end
|
|
43
46
|
|
|
44
47
|
private
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# frozen_string_literal: false
|
|
2
|
+
|
|
3
|
+
module SplitIoClient
|
|
4
|
+
module Engine::Models
|
|
5
|
+
class EventActiveSubscriptions
|
|
6
|
+
attr_accessor :triggered, :handler
|
|
7
|
+
|
|
8
|
+
def initialize(triggered, handler)
|
|
9
|
+
@triggered = triggered
|
|
10
|
+
@handler = handler
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
class SplitIoClient::Engine::Models::SdkInternalEvent
|
|
2
|
+
SDK_READY = 'SDK_READY'
|
|
3
|
+
FLAGS_UPDATED = 'FLAGS_UPDATED'
|
|
4
|
+
FLAG_KILLED_NOTIFICATION = 'FLAG_KILLED_NOTIFICATION'
|
|
5
|
+
SEGMENTS_UPDATED = 'SEGMENTS_UPDATED'
|
|
6
|
+
RB_SEGMENTS_UPDATED = 'RB_SEGMENTS_UPDATED'
|
|
7
|
+
LARGE_SEGMENTS_UPDATED = 'LARGE_SEGMENTS_UPDATED'
|
|
8
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# frozen_string_literal: false
|
|
2
|
+
|
|
3
|
+
module SplitIoClient
|
|
4
|
+
module Engine
|
|
5
|
+
module Models
|
|
6
|
+
class SdkInternalEventNotification
|
|
7
|
+
attr_reader :internal_event, :metadata
|
|
8
|
+
|
|
9
|
+
def initialize(internal_event, metadata)
|
|
10
|
+
@internal_event = internal_event
|
|
11
|
+
@metadata = metadata
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
module SplitIoClient
|
|
4
4
|
module Engine
|
|
5
5
|
class StatusManager
|
|
6
|
-
def initialize(config)
|
|
6
|
+
def initialize(config, internal_events_queue)
|
|
7
7
|
@config = config
|
|
8
8
|
@sdk_ready = Concurrent::CountDownLatch.new(1)
|
|
9
|
+
@internal_events_queue = internal_events_queue
|
|
9
10
|
end
|
|
10
11
|
|
|
11
12
|
def ready?
|
|
@@ -19,6 +20,11 @@ module SplitIoClient
|
|
|
19
20
|
|
|
20
21
|
@sdk_ready.count_down
|
|
21
22
|
@config.logger.info('SplitIO SDK is ready')
|
|
23
|
+
@internal_events_queue.push(
|
|
24
|
+
SplitIoClient::Engine::Models::SdkInternalEventNotification.new(
|
|
25
|
+
SplitIoClient::Engine::Models::SdkInternalEvent::SDK_READY, nil
|
|
26
|
+
)
|
|
27
|
+
)
|
|
22
28
|
end
|
|
23
29
|
|
|
24
30
|
def wait_until_ready(seconds = nil)
|
|
@@ -47,13 +47,13 @@ module SplitIoClient
|
|
|
47
47
|
connected = false
|
|
48
48
|
|
|
49
49
|
if @config.streaming_enabled
|
|
50
|
-
@config.logger.debug('Starting Streaming mode ...')
|
|
50
|
+
@config.logger.debug('Starting Streaming mode ...') if @config.debug_enabled
|
|
51
51
|
start_push_status_monitor
|
|
52
52
|
connected = @push_manager.start_sse
|
|
53
53
|
end
|
|
54
54
|
|
|
55
55
|
unless connected
|
|
56
|
-
@config.logger.debug('Starting Polling mode ...')
|
|
56
|
+
@config.logger.debug('Starting Polling mode ...') if @config.debug_enabled
|
|
57
57
|
@synchronizer.start_periodic_fetch
|
|
58
58
|
record_telemetry(Telemetry::Domain::Constants::SYNC_MODE, SYNC_MODE_POLLING)
|
|
59
59
|
end
|
|
@@ -92,7 +92,7 @@ module SplitIoClient
|
|
|
92
92
|
|
|
93
93
|
def process_connected
|
|
94
94
|
if @sse_connected.value
|
|
95
|
-
@config.logger.debug('Streaming already connected.')
|
|
95
|
+
@config.logger.debug('Streaming already connected.') if @config.debug_enabled
|
|
96
96
|
return
|
|
97
97
|
end
|
|
98
98
|
|
|
@@ -107,7 +107,7 @@ module SplitIoClient
|
|
|
107
107
|
|
|
108
108
|
def process_forced_stop
|
|
109
109
|
unless @sse_connected.value
|
|
110
|
-
@config.logger.debug('Streaming already disconnected.')
|
|
110
|
+
@config.logger.debug('Streaming already disconnected.') if @config.debug_enabled
|
|
111
111
|
return
|
|
112
112
|
end
|
|
113
113
|
|
|
@@ -120,7 +120,7 @@ module SplitIoClient
|
|
|
120
120
|
|
|
121
121
|
def process_disconnect(reconnect)
|
|
122
122
|
unless @sse_connected.value
|
|
123
|
-
@config.logger.debug('Streaming already disconnected.')
|
|
123
|
+
@config.logger.debug('Streaming already disconnected.') if @config.debug_enabled
|
|
124
124
|
return
|
|
125
125
|
end
|
|
126
126
|
|
|
@@ -169,12 +169,16 @@ module SplitIoClient
|
|
|
169
169
|
when Constants::PUSH_SUBSYSTEM_OFF
|
|
170
170
|
process_push_shutdown
|
|
171
171
|
else
|
|
172
|
-
|
|
172
|
+
log_if_debug('Incorrect push status type.')
|
|
173
173
|
end
|
|
174
174
|
end
|
|
175
175
|
rescue StandardError => e
|
|
176
176
|
@config.logger.error("Push status handler error: #{e.inspect}")
|
|
177
177
|
end
|
|
178
178
|
end
|
|
179
|
+
|
|
180
|
+
def log_if_debug(msg)
|
|
181
|
+
@config.logger.debug(msg) if @config.debug_enabled
|
|
182
|
+
end
|
|
179
183
|
end
|
|
180
184
|
end
|
|
@@ -45,6 +45,7 @@ module SplitIoClient
|
|
|
45
45
|
|
|
46
46
|
register_factory
|
|
47
47
|
|
|
48
|
+
build_events_manager
|
|
48
49
|
build_telemetry_components
|
|
49
50
|
build_flag_sets_filter
|
|
50
51
|
build_repositories
|
|
@@ -53,13 +54,13 @@ module SplitIoClient
|
|
|
53
54
|
build_unique_keys_tracker
|
|
54
55
|
build_impressions_components
|
|
55
56
|
|
|
56
|
-
@status_manager = Engine::StatusManager.new(@config)
|
|
57
|
+
@status_manager = Engine::StatusManager.new(@config, @internal_events_queue)
|
|
57
58
|
@split_validator = SplitIoClient::Validators.new(@config)
|
|
58
59
|
@evaluator = Engine::Parser::Evaluator.new(@segments_repository, @splits_repository, @rule_based_segment_repository, @config)
|
|
59
60
|
|
|
60
61
|
start!
|
|
61
62
|
fallback_treatment_calculator = SplitIoClient::Engine::FallbackTreatmentCalculator.new(@config.fallback_treatments_configuration)
|
|
62
|
-
@client = SplitClient.new(@api_key, repositories, @status_manager, @config, @impressions_manager, @evaluation_producer, @evaluator, @split_validator, fallback_treatment_calculator)
|
|
63
|
+
@client = SplitClient.new(@api_key, repositories, @status_manager, @config, @impressions_manager, @evaluation_producer, @evaluator, @split_validator, fallback_treatment_calculator, @events_manager)
|
|
63
64
|
@manager = SplitManager.new(@splits_repository, @status_manager, @config)
|
|
64
65
|
end
|
|
65
66
|
|
|
@@ -219,9 +220,9 @@ module SplitIoClient
|
|
|
219
220
|
else
|
|
220
221
|
@flag_sets_repository = SplitIoClient::Cache::Repositories::MemoryFlagSetsRepository.new(@config.flag_sets_filter)
|
|
221
222
|
end
|
|
222
|
-
@splits_repository = SplitsRepository.new(@config, @flag_sets_repository, @flag_sets_filter)
|
|
223
|
-
@segments_repository = SegmentsRepository.new(@config)
|
|
224
|
-
@rule_based_segment_repository = RuleBasedSegmentsRepository.new(@config)
|
|
223
|
+
@splits_repository = SplitsRepository.new(@config, @flag_sets_repository, @flag_sets_filter, @internal_events_queue)
|
|
224
|
+
@segments_repository = SegmentsRepository.new(@config, @internal_events_queue)
|
|
225
|
+
@rule_based_segment_repository = RuleBasedSegmentsRepository.new(@config, @internal_events_queue)
|
|
225
226
|
@impressions_repository = ImpressionsRepository.new(@config)
|
|
226
227
|
@events_repository = EventsRepository.new(@config, @api_key, @runtime_producer)
|
|
227
228
|
end
|
|
@@ -265,5 +266,19 @@ module SplitIoClient
|
|
|
265
266
|
def build_flag_sets_filter
|
|
266
267
|
@flag_sets_filter = SplitIoClient::Cache::Filter::FlagSetsFilter.new(@config.flag_sets_filter)
|
|
267
268
|
end
|
|
269
|
+
|
|
270
|
+
def build_events_manager
|
|
271
|
+
@events_manager = Engine::Events::EventsManager.new(Engine::Events::EventsManagerConfig.new,
|
|
272
|
+
Engine::Events::EventsDelivery.new(@config),
|
|
273
|
+
@config)
|
|
274
|
+
if @config.consumer?
|
|
275
|
+
@internal_events_queue = Engine::Events::NoOpEventsQueue.new
|
|
276
|
+
return
|
|
277
|
+
end
|
|
278
|
+
|
|
279
|
+
@internal_events_queue = Queue.new
|
|
280
|
+
@events_task = Engine::Events::EventsTask.new(@events_manager.method(:notify_internal_event), @internal_events_queue, @config)
|
|
281
|
+
@events_task.start
|
|
282
|
+
end
|
|
268
283
|
end
|
|
269
284
|
end
|
|
@@ -38,23 +38,23 @@ module SplitIoClient
|
|
|
38
38
|
|
|
39
39
|
def close(status = nil)
|
|
40
40
|
unless connected?
|
|
41
|
-
@config.logger.debug('SSEClient already disconected.')
|
|
41
|
+
@config.logger.debug('SSEClient already disconected.') if @config.debug_enabled
|
|
42
42
|
return
|
|
43
43
|
end
|
|
44
|
-
@config.logger.debug("Closing SSEClient socket")
|
|
44
|
+
@config.logger.debug("Closing SSEClient socket") if @config.debug_enabled
|
|
45
45
|
|
|
46
|
+
push_status(status)
|
|
46
47
|
@connected.make_false
|
|
47
48
|
@socket.sync_close = true if @socket.is_a? OpenSSL::SSL::SSLSocket
|
|
48
49
|
@socket.close
|
|
49
|
-
@config.logger.debug("SSEClient socket state #{@socket.state}") if @socket.is_a? OpenSSL::SSL::SSLSocket
|
|
50
|
-
push_status(status)
|
|
50
|
+
@config.logger.debug("SSEClient socket state #{@socket.state}") if @socket.is_a? OpenSSL::SSL::SSLSocket && @config.debug_enabled
|
|
51
51
|
rescue StandardError => e
|
|
52
52
|
@config.logger.error("SSEClient close Error: #{e.inspect}")
|
|
53
53
|
end
|
|
54
54
|
|
|
55
55
|
def start(url)
|
|
56
56
|
if connected?
|
|
57
|
-
@config.logger.debug('SSEClient already running.')
|
|
57
|
+
@config.logger.debug('SSEClient already running.') if @config.debug_enabled
|
|
58
58
|
return true
|
|
59
59
|
end
|
|
60
60
|
|
|
@@ -96,18 +96,17 @@ module SplitIoClient
|
|
|
96
96
|
|
|
97
97
|
raise 'eof exception' if partial_data == :eof
|
|
98
98
|
rescue IO::WaitReadable => e
|
|
99
|
-
@config.logger.debug("SSE client IO::WaitReadable transient error: #{e.inspect}")
|
|
99
|
+
@config.logger.debug("SSE client IO::WaitReadable transient error: #{e.inspect}") if @config.debug_enabled
|
|
100
100
|
IO.select([@socket], nil, nil, @read_timeout)
|
|
101
101
|
retry
|
|
102
102
|
rescue Errno::EAGAIN => e
|
|
103
|
-
@config.logger.debug("SSE client transient error: #{e.inspect}")
|
|
103
|
+
@config.logger.debug("SSE client transient error: #{e.inspect}") if @config.debug_enabled
|
|
104
104
|
IO.select([@socket], nil, nil, @read_timeout)
|
|
105
105
|
retry
|
|
106
106
|
rescue Errno::ETIMEDOUT => e
|
|
107
107
|
@config.logger.error("SSE read operation timed out!: #{e.inspect}")
|
|
108
108
|
return Constants::PUSH_RETRYABLE_ERROR
|
|
109
109
|
rescue EOFError => e
|
|
110
|
-
puts "SSE read operation EOF Exception!: #{e.inspect}"
|
|
111
110
|
@config.logger.error("SSE read operation EOF Exception!: #{e.inspect}")
|
|
112
111
|
raise 'eof exception'
|
|
113
112
|
rescue Errno::EBADF, IOError => e
|
|
@@ -125,12 +124,12 @@ module SplitIoClient
|
|
|
125
124
|
return Constants::PUSH_RETRYABLE_ERROR
|
|
126
125
|
end
|
|
127
126
|
rescue Errno::EBADF
|
|
128
|
-
@config.logger.debug("SSE socket is not connected (Errno::EBADF)")
|
|
127
|
+
@config.logger.debug("SSE socket is not connected (Errno::EBADF)") if @config.debug_enabled
|
|
129
128
|
break
|
|
130
129
|
rescue RuntimeError
|
|
131
130
|
raise 'eof exception'
|
|
132
131
|
rescue Exception => e
|
|
133
|
-
@config.logger.debug("SSE socket is not connected: #{e.inspect}")
|
|
132
|
+
@config.logger.debug("SSE socket is not connected: #{e.inspect}") if @config.debug_enabled
|
|
134
133
|
break
|
|
135
134
|
end
|
|
136
135
|
|
|
@@ -156,7 +155,7 @@ module SplitIoClient
|
|
|
156
155
|
return unless @first_event.value
|
|
157
156
|
|
|
158
157
|
response_code = @event_parser.first_event(data)
|
|
159
|
-
@config.logger.debug("SSE client first event code: #{response_code}")
|
|
158
|
+
@config.logger.debug("SSE client first event code: #{response_code}") if @config.debug_enabled
|
|
160
159
|
|
|
161
160
|
error_event = false
|
|
162
161
|
events = @event_parser.parse(data)
|
|
@@ -165,7 +164,7 @@ module SplitIoClient
|
|
|
165
164
|
|
|
166
165
|
if response_code == OK_CODE && !error_event
|
|
167
166
|
@connected.make_true
|
|
168
|
-
@config.logger.debug("SSE client first event Connected is true")
|
|
167
|
+
@config.logger.debug("SSE client first event Connected is true") if @config.debug_enabled
|
|
169
168
|
@telemetry_runtime_producer.record_streaming_event(Telemetry::Domain::Constants::SSE_CONNECTION_ESTABLISHED, nil)
|
|
170
169
|
push_status(Constants::PUSH_CONNECTED)
|
|
171
170
|
end
|
|
@@ -202,7 +201,7 @@ module SplitIoClient
|
|
|
202
201
|
end
|
|
203
202
|
|
|
204
203
|
def process_data(partial_data)
|
|
205
|
-
@config.logger.debug("Event partial data: #{partial_data}")
|
|
204
|
+
@config.logger.debug("Event partial data: #{partial_data}") if @config.debug_enabled
|
|
206
205
|
return if partial_data.nil? || partial_data == KEEP_ALIVE_RESPONSE
|
|
207
206
|
|
|
208
207
|
events = @event_parser.parse(partial_data)
|
|
@@ -220,7 +219,7 @@ module SplitIoClient
|
|
|
220
219
|
req << "SplitSDKMachineName: #{@config.machine_name}\r\n"
|
|
221
220
|
req << "SplitSDKClientKey: #{@api_key.split(//).last(4).join}\r\n" unless @api_key.nil?
|
|
222
221
|
req << "Cache-Control: no-cache\r\n\r\n"
|
|
223
|
-
@config.logger.debug("Request info: #{req}")
|
|
222
|
+
@config.logger.debug("Request info: #{req}") if @config.debug_enabled
|
|
224
223
|
req
|
|
225
224
|
end
|
|
226
225
|
|
|
@@ -255,7 +254,7 @@ module SplitIoClient
|
|
|
255
254
|
def push_status(status)
|
|
256
255
|
return if status.nil?
|
|
257
256
|
|
|
258
|
-
@config.logger.debug("Pushing new sse status: #{status}")
|
|
257
|
+
@config.logger.debug("Pushing new sse status: #{status}") if @config.debug_enabled
|
|
259
258
|
@status_queue.push(status)
|
|
260
259
|
end
|
|
261
260
|
end
|
|
@@ -29,14 +29,14 @@ module SplitIoClient
|
|
|
29
29
|
|
|
30
30
|
events
|
|
31
31
|
rescue StandardError => e
|
|
32
|
-
@config.logger.debug("Error during parsing a event: #{e.inspect}")
|
|
32
|
+
@config.logger.debug("Error during parsing a event: #{e.inspect}") if @config.debug_enabled
|
|
33
33
|
[]
|
|
34
34
|
end
|
|
35
35
|
|
|
36
36
|
def first_event(raw_data)
|
|
37
37
|
raw_data.split("\n")[0].split(' ')[1].to_i
|
|
38
38
|
rescue StandardError => e
|
|
39
|
-
@config.logger.
|
|
39
|
+
@config.logger.error("Error parsing first event: #{e.inspect}")
|
|
40
40
|
BAD_REQUEST_CODE
|
|
41
41
|
end
|
|
42
42
|
|
|
@@ -42,12 +42,12 @@ module SplitIoClient
|
|
|
42
42
|
@telemetry_runtime_producer.record_streaming_event(Telemetry::Domain::Constants::STREAMING_STATUS, DISABLED)
|
|
43
43
|
push_status(Constants::PUSH_SUBSYSTEM_OFF)
|
|
44
44
|
else
|
|
45
|
-
@config.logger.error("Incorrect event type: #{incoming_notification}")
|
|
45
|
+
@config.logger.error("Incorrect event type: #{incoming_notification}") if @config.debug_enabled
|
|
46
46
|
end
|
|
47
47
|
end
|
|
48
48
|
|
|
49
49
|
def process_event_occupancy(channel, publishers)
|
|
50
|
-
@config.logger.debug("Processed occupancy event with #{publishers} publishers. Channel: #{channel}")
|
|
50
|
+
@config.logger.debug("Processed occupancy event with #{publishers} publishers. Channel: #{channel}") if @config.debug_enabled
|
|
51
51
|
|
|
52
52
|
update_publishers(channel, publishers)
|
|
53
53
|
|
|
@@ -76,7 +76,7 @@ module SplitIoClient
|
|
|
76
76
|
end
|
|
77
77
|
|
|
78
78
|
def push_status(status)
|
|
79
|
-
@config.logger.debug("Pushing occupancy status: #{status}")
|
|
79
|
+
@config.logger.debug("Pushing occupancy status: #{status}") if @config.debug_enabled
|
|
80
80
|
@status_queue.push(status)
|
|
81
81
|
end
|
|
82
82
|
end
|
|
@@ -14,13 +14,13 @@ module SplitIoClient
|
|
|
14
14
|
|
|
15
15
|
def add_to_queue(change_number, segment_name)
|
|
16
16
|
item = { change_number: change_number, segment_name: segment_name }
|
|
17
|
-
@config.logger.debug("SegmentsWorker add to queue #{item}")
|
|
17
|
+
@config.logger.debug("SegmentsWorker add to queue #{item}") if @config.debug_enabled
|
|
18
18
|
@queue.push(item)
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
def start
|
|
22
22
|
if @running.value
|
|
23
|
-
@config.logger.debug('segments worker already running.')
|
|
23
|
+
@config.logger.debug('segments worker already running.') if @config.debug_enabled
|
|
24
24
|
return
|
|
25
25
|
end
|
|
26
26
|
|
|
@@ -30,7 +30,7 @@ module SplitIoClient
|
|
|
30
30
|
|
|
31
31
|
def stop
|
|
32
32
|
unless @running.value
|
|
33
|
-
@config.logger.debug('segments worker not running.')
|
|
33
|
+
@config.logger.debug('segments worker not running.') if @config.debug_enabled
|
|
34
34
|
return
|
|
35
35
|
end
|
|
36
36
|
|
|
@@ -44,7 +44,7 @@ module SplitIoClient
|
|
|
44
44
|
while (item = @queue.pop)
|
|
45
45
|
segment_name = item[:segment_name]
|
|
46
46
|
cn = item[:change_number]
|
|
47
|
-
@config.logger.debug("SegmentsWorker change_number dequeue #{segment_name}, #{cn}")
|
|
47
|
+
@config.logger.debug("SegmentsWorker change_number dequeue #{segment_name}, #{cn}") if @config.debug_enabled
|
|
48
48
|
|
|
49
49
|
@synchronizer.fetch_segment(segment_name, cn)
|
|
50
50
|
end
|
|
@@ -18,7 +18,7 @@ module SplitIoClient
|
|
|
18
18
|
|
|
19
19
|
def start
|
|
20
20
|
if @running.value
|
|
21
|
-
@config.logger.debug('feature_flags_worker already running.')
|
|
21
|
+
@config.logger.debug('feature_flags_worker already running.') if @config.debug_enabled
|
|
22
22
|
return
|
|
23
23
|
end
|
|
24
24
|
|
|
@@ -28,7 +28,7 @@ module SplitIoClient
|
|
|
28
28
|
|
|
29
29
|
def stop
|
|
30
30
|
unless @running.value
|
|
31
|
-
@config.logger.debug('feature_flags_worker not running.')
|
|
31
|
+
@config.logger.debug('feature_flags_worker not running.') if @config.debug_enabled
|
|
32
32
|
return
|
|
33
33
|
end
|
|
34
34
|
|
|
@@ -37,7 +37,7 @@ module SplitIoClient
|
|
|
37
37
|
end
|
|
38
38
|
|
|
39
39
|
def add_to_queue(notification)
|
|
40
|
-
@config.logger.debug("feature_flags_worker add to queue #{notification.data['changeNumber']}")
|
|
40
|
+
@config.logger.debug("feature_flags_worker add to queue #{notification.data['changeNumber']}") if @config.debug_enabled
|
|
41
41
|
@queue.push(notification)
|
|
42
42
|
end
|
|
43
43
|
|
|
@@ -52,7 +52,9 @@ module SplitIoClient
|
|
|
52
52
|
|
|
53
53
|
def perform
|
|
54
54
|
while (notification = @queue.pop)
|
|
55
|
-
@config.
|
|
55
|
+
if @config.debug_enabled
|
|
56
|
+
@config.logger.debug("feature_flags_worker change_number dequeue #{notification.data['changeNumber']}")
|
|
57
|
+
end
|
|
56
58
|
case notification.data['type']
|
|
57
59
|
when SSE::EventSource::EventTypes::SPLIT_UPDATE
|
|
58
60
|
success = update_feature_flag(notification)
|
|
@@ -117,7 +119,9 @@ module SplitIoClient
|
|
|
117
119
|
def kill_feature_flag(notification)
|
|
118
120
|
return if @feature_flags_repository.get_change_number.to_i > notification.data['changeNumber']
|
|
119
121
|
|
|
120
|
-
@config.
|
|
122
|
+
if @config.debug_enabled
|
|
123
|
+
@config.logger.debug("feature_flags_worker kill #{notification.data['splitName']}, #{notification.data['changeNumber']}")
|
|
124
|
+
end
|
|
121
125
|
@feature_flags_repository.kill(notification.data['changeNumber'],
|
|
122
126
|
notification.data['splitName'],
|
|
123
127
|
notification.data['defaultTreatment'])
|