splitclient-rb 7.3.3.pre.rc18-java → 7.3.4.pre.rc1-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/.rubocop.yml +5 -1
- data/CHANGES.txt +10 -0
- data/lib/splitclient-rb/constants.rb +1 -0
- data/lib/splitclient-rb/engine/sync_manager.rb +61 -46
- data/lib/splitclient-rb/split_factory.rb +59 -20
- data/lib/splitclient-rb/sse/event_source/client.rb +29 -27
- data/lib/splitclient-rb/sse/notification_manager_keeper.rb +11 -18
- data/lib/splitclient-rb/sse/sse_handler.rb +10 -39
- data/lib/splitclient-rb/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6b87c29efc94839289ddc4bc83b2909854ba3a9b
|
4
|
+
data.tar.gz: 7163fc08290ace163cb8e7815060673d0a68a1f7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b160683bc39ed4adb87223be199bbfbcdffef63ae383e4f9d72156d7a5fabcf862eec3ff4735cee6366d260a1df4711f682f1dd58e197f46d9373292c2843dbf
|
7
|
+
data.tar.gz: a8c9b5e4a447687ae1c2706c158376b2ac7da5c756eb40e8a9c485f7ba296fbf72c6894b310bd3a5fd02ca4145d175316a10d58d1b9a09aff65eedd46f0d43fc
|
data/.rubocop.yml
CHANGED
@@ -10,6 +10,7 @@ Metrics/MethodLength:
|
|
10
10
|
Max: 20
|
11
11
|
Exclude:
|
12
12
|
- lib/splitclient-rb/telemetry/memory/memory_synchronizer.rb
|
13
|
+
- lib/splitclient-rb/engine/sync_manager.rb
|
13
14
|
|
14
15
|
Metrics/ClassLength:
|
15
16
|
Max: 150
|
@@ -17,9 +18,10 @@ Metrics/ClassLength:
|
|
17
18
|
- lib/splitclient-rb/telemetry/memory/memory_synchronizer.rb
|
18
19
|
|
19
20
|
Metrics/CyclomaticComplexity:
|
20
|
-
Max:
|
21
|
+
Max: 11
|
21
22
|
|
22
23
|
Metrics/ParameterLists:
|
24
|
+
Max: 8
|
23
25
|
Exclude:
|
24
26
|
- lib/splitclient-rb/engine/sync_manager.rb
|
25
27
|
|
@@ -32,6 +34,7 @@ Metrics/LineLength:
|
|
32
34
|
- spec/engine/auth_api_client_spec.rb
|
33
35
|
- spec/telemetry/synchronizer_spec.rb
|
34
36
|
- spec/splitclient/split_config_spec.rb
|
37
|
+
- spec/engine/push_manager_spec.rb
|
35
38
|
|
36
39
|
Style/BracesAroundHashParameters:
|
37
40
|
Exclude:
|
@@ -65,3 +68,4 @@ AllCops:
|
|
65
68
|
- spec/telemetry/synchronizer_spec.rb
|
66
69
|
- lib/splitclient-rb/engine/synchronizer.rb
|
67
70
|
- tmp/**/*
|
71
|
+
- lib/splitclient-rb/sse/event_source/client.rb
|
data/CHANGES.txt
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
CHANGES
|
2
2
|
|
3
|
+
7.3.3 (Jan 28, 2021)
|
4
|
+
- Fixed edge cases where the sdk lost streaming connection.
|
5
|
+
- Updated default auth service url to https://auth.split.io/api/v2/auth
|
6
|
+
- Updated dependencies:
|
7
|
+
- faraday to >= 0.8, < 2.0
|
8
|
+
- net-http-persistent to >= 2.9, < 5.0
|
9
|
+
- redis to >= 4.0.0, < 5.0
|
10
|
+
- socketry to >= 0.4, < 1.0
|
11
|
+
- thread_safe to ~> 0.3
|
12
|
+
|
3
13
|
7.3.2 (Dec 10, 2021)
|
4
14
|
- Updated the readiness flow to be more consistent with the other sdks and improve the readiness time.
|
5
15
|
- Updated the name of telemety key latencies in Redis.
|
@@ -6,35 +6,23 @@ module SplitIoClient
|
|
6
6
|
SYNC_MODE_STREAMING = 0
|
7
7
|
SYNC_MODE_POLLING = 1
|
8
8
|
|
9
|
-
def initialize(
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
)
|
18
|
-
@synchronizer = synchronizer
|
19
|
-
notification_manager_keeper = SSE::NotificationManagerKeeper.new(config, telemetry_runtime_producer) do |manager|
|
20
|
-
manager.on_action { |action| process_action(action) }
|
21
|
-
end
|
22
|
-
@sse_handler = SSE::SSEHandler.new(
|
23
|
-
{ config: config, api_key: api_key },
|
24
|
-
@synchronizer,
|
25
|
-
repositories,
|
26
|
-
notification_manager_keeper,
|
27
|
-
telemetry_runtime_producer
|
28
|
-
) do |handler|
|
29
|
-
handler.on_action { |action| process_action(action) }
|
30
|
-
end
|
31
|
-
|
32
|
-
@push_manager = PushManager.new(config, @sse_handler, api_key, telemetry_runtime_producer)
|
33
|
-
@sse_connected = Concurrent::AtomicBoolean.new(false)
|
9
|
+
def initialize(config,
|
10
|
+
synchronizer,
|
11
|
+
telemetry_runtime_producer,
|
12
|
+
telemetry_synchronizer,
|
13
|
+
status_manager,
|
14
|
+
sse_handler,
|
15
|
+
push_manager,
|
16
|
+
status_queue)
|
34
17
|
@config = config
|
18
|
+
@synchronizer = synchronizer
|
35
19
|
@telemetry_runtime_producer = telemetry_runtime_producer
|
36
20
|
@telemetry_synchronizer = telemetry_synchronizer
|
37
21
|
@status_manager = status_manager
|
22
|
+
@sse_handler = sse_handler
|
23
|
+
@push_manager = push_manager
|
24
|
+
@status_queue = status_queue
|
25
|
+
@sse_connected = Concurrent::AtomicBoolean.new(false)
|
38
26
|
end
|
39
27
|
|
40
28
|
def start
|
@@ -55,6 +43,7 @@ module SplitIoClient
|
|
55
43
|
|
56
44
|
if @config.streaming_enabled
|
57
45
|
@config.logger.debug('Starting Straming mode ...')
|
46
|
+
start_push_status_monitor
|
58
47
|
connected = @push_manager.start_sse
|
59
48
|
end
|
60
49
|
|
@@ -66,27 +55,6 @@ module SplitIoClient
|
|
66
55
|
end
|
67
56
|
end
|
68
57
|
|
69
|
-
def process_action(action)
|
70
|
-
case action
|
71
|
-
when Constants::PUSH_CONNECTED
|
72
|
-
process_connected
|
73
|
-
when Constants::PUSH_RETRYABLE_ERROR
|
74
|
-
process_disconnect(true)
|
75
|
-
when Constants::PUSH_NONRETRYABLE_ERROR
|
76
|
-
process_disconnect(false)
|
77
|
-
when Constants::PUSH_SUBSYSTEM_DOWN
|
78
|
-
process_subsystem_down
|
79
|
-
when Constants::PUSH_SUBSYSTEM_READY
|
80
|
-
process_subsystem_ready
|
81
|
-
when Constants::PUSH_SUBSYSTEM_OFF
|
82
|
-
process_push_shutdown
|
83
|
-
else
|
84
|
-
@config.logger.debug('Incorrect action type.')
|
85
|
-
end
|
86
|
-
rescue StandardError => e
|
87
|
-
@config.logger.error("process_action error: #{e.inspect}")
|
88
|
-
end
|
89
|
-
|
90
58
|
def process_subsystem_ready
|
91
59
|
@synchronizer.stop_periodic_fetch
|
92
60
|
@synchronizer.sync_all
|
@@ -124,6 +92,19 @@ module SplitIoClient
|
|
124
92
|
@config.logger.error("process_connected error: #{e.inspect}")
|
125
93
|
end
|
126
94
|
|
95
|
+
def process_forced_stop
|
96
|
+
unless @sse_connected.value
|
97
|
+
@config.logger.debug('Streaming already disconnected.')
|
98
|
+
return
|
99
|
+
end
|
100
|
+
|
101
|
+
@sse_connected.make_false
|
102
|
+
@synchronizer.start_periodic_fetch
|
103
|
+
record_telemetry(Telemetry::Domain::Constants::SYNC_MODE, SYNC_MODE_POLLING)
|
104
|
+
rescue StandardError => e
|
105
|
+
@config.logger.error("process_connected error: #{e.inspect}")
|
106
|
+
end
|
107
|
+
|
127
108
|
def process_disconnect(reconnect)
|
128
109
|
unless @sse_connected.value
|
129
110
|
@config.logger.debug('Streaming already disconnected.')
|
@@ -147,6 +128,40 @@ module SplitIoClient
|
|
147
128
|
def record_telemetry(type, data)
|
148
129
|
@telemetry_runtime_producer.record_streaming_event(type, data)
|
149
130
|
end
|
131
|
+
|
132
|
+
def start_push_status_monitor
|
133
|
+
@config.threads[:push_status_handler] = Thread.new do
|
134
|
+
@config.logger.debug('Starting push status handler ...') if @config.debug_enabled
|
135
|
+
incoming_push_status_handler
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
def incoming_push_status_handler
|
140
|
+
while (status = @status_queue.pop)
|
141
|
+
@config.logger.debug("Push status handler dequeue #{status}") if @config.debug_enabled
|
142
|
+
|
143
|
+
case status
|
144
|
+
when Constants::PUSH_CONNECTED
|
145
|
+
process_connected
|
146
|
+
when Constants::PUSH_RETRYABLE_ERROR
|
147
|
+
process_disconnect(true)
|
148
|
+
when Constants::PUSH_FORCED_STOP
|
149
|
+
process_forced_stop
|
150
|
+
when Constants::PUSH_NONRETRYABLE_ERROR
|
151
|
+
process_disconnect(false)
|
152
|
+
when Constants::PUSH_SUBSYSTEM_DOWN
|
153
|
+
process_subsystem_down
|
154
|
+
when Constants::PUSH_SUBSYSTEM_READY
|
155
|
+
process_subsystem_ready
|
156
|
+
when Constants::PUSH_SUBSYSTEM_OFF
|
157
|
+
process_push_shutdown
|
158
|
+
else
|
159
|
+
@config.logger.debug('Incorrect push status type.')
|
160
|
+
end
|
161
|
+
end
|
162
|
+
rescue StandardError => e
|
163
|
+
@config.logger.error("Push status handler error: #{e.inspect}")
|
164
|
+
end
|
150
165
|
end
|
151
166
|
end
|
152
167
|
end
|
@@ -33,15 +33,10 @@ module SplitIoClient
|
|
33
33
|
register_factory
|
34
34
|
|
35
35
|
build_telemetry_components
|
36
|
+
build_repositories
|
37
|
+
build_impressions_components
|
38
|
+
build_telemetry_synchronizer
|
36
39
|
|
37
|
-
@splits_repository = SplitsRepository.new(@config)
|
38
|
-
@segments_repository = SegmentsRepository.new(@config)
|
39
|
-
@impressions_repository = ImpressionsRepository.new(@config)
|
40
|
-
@events_repository = EventsRepository.new(@config, @api_key, @runtime_producer)
|
41
|
-
@impression_counter = SplitIoClient::Engine::Common::ImpressionCounter.new
|
42
|
-
@impressions_manager = SplitIoClient::Engine::Common::ImpressionManager.new(@config, @impressions_repository, @impression_counter, @runtime_producer)
|
43
|
-
@telemetry_api = SplitIoClient::Api::TelemetryApi.new(@config, @api_key, @runtime_producer)
|
44
|
-
@telemetry_synchronizer = Telemetry::Synchronizer.new(@config, @telemetry_consumers, @init_producer, repositories, @telemetry_api)
|
45
40
|
@status_manager = Engine::StatusManager.new(@config)
|
46
41
|
|
47
42
|
start!
|
@@ -59,18 +54,12 @@ module SplitIoClient
|
|
59
54
|
return
|
60
55
|
end
|
61
56
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
segment_fetcher: segment_fetcher,
|
67
|
-
imp_counter: @impression_counter,
|
68
|
-
telemetry_runtime_producer: @runtime_producer,
|
69
|
-
telemetry_synchronizer: @telemetry_synchronizer
|
70
|
-
}
|
57
|
+
build_fetchers
|
58
|
+
build_synchronizer
|
59
|
+
build_streaming_components
|
60
|
+
build_sync_manager
|
71
61
|
|
72
|
-
|
73
|
-
SplitIoClient::Engine::SyncManager.new(repositories, @api_key, @config, synchronizer, @runtime_producer, @telemetry_synchronizer, @status_manager).start
|
62
|
+
@sync_manager.start
|
74
63
|
end
|
75
64
|
|
76
65
|
def stop!
|
@@ -166,6 +155,56 @@ module SplitIoClient
|
|
166
155
|
@runtime_producer = Telemetry::RuntimeProducer.new(@config)
|
167
156
|
|
168
157
|
@telemetry_consumers = { init: @init_consumer, evaluation: @evaluation_consumer, runtime: @runtime_consumer }
|
169
|
-
end
|
158
|
+
end
|
159
|
+
|
160
|
+
def build_fetchers
|
161
|
+
@split_fetcher = SplitFetcher.new(@splits_repository, @api_key, @config, @runtime_producer)
|
162
|
+
@segment_fetcher = SegmentFetcher.new(@segments_repository, @api_key, @config, @runtime_producer)
|
163
|
+
end
|
164
|
+
|
165
|
+
def build_synchronizer
|
166
|
+
params = {
|
167
|
+
split_fetcher: @split_fetcher,
|
168
|
+
segment_fetcher: @segment_fetcher,
|
169
|
+
imp_counter: @impression_counter,
|
170
|
+
telemetry_runtime_producer: @runtime_producer,
|
171
|
+
telemetry_synchronizer: @telemetry_synchronizer
|
172
|
+
}
|
173
|
+
|
174
|
+
@synchronizer = Engine::Synchronizer.new(repositories, @api_key, @config, params)
|
175
|
+
end
|
176
|
+
|
177
|
+
def build_streaming_components
|
178
|
+
@push_status_queue = Queue.new
|
179
|
+
splits_worker = SSE::Workers::SplitsWorker.new(@synchronizer, @config, @splits_repository)
|
180
|
+
segments_worker = SSE::Workers::SegmentsWorker.new(@synchronizer, @config, @segments_repository)
|
181
|
+
notification_manager_keeper = SSE::NotificationManagerKeeper.new(@config, @runtime_producer, @push_status_queue)
|
182
|
+
notification_processor = SSE::NotificationProcessor.new(@config, splits_worker, segments_worker)
|
183
|
+
event_parser = SSE::EventSource::EventParser.new(config)
|
184
|
+
sse_client = SSE::EventSource::Client.new(@config, @api_key, @runtime_producer, event_parser, notification_manager_keeper, notification_processor, @push_status_queue)
|
185
|
+
@sse_handler = SSE::SSEHandler.new(@config, splits_worker, segments_worker, sse_client)
|
186
|
+
@push_manager = Engine::PushManager.new(@config, @sse_handler, @api_key, @runtime_producer)
|
187
|
+
end
|
188
|
+
|
189
|
+
def build_sync_manager
|
190
|
+
@sync_manager = Engine::SyncManager.new(@config, @synchronizer, @runtime_producer, @telemetry_synchronizer, @status_manager, @sse_handler, @push_manager, @push_status_queue)
|
191
|
+
end
|
192
|
+
|
193
|
+
def build_repositories
|
194
|
+
@splits_repository = SplitsRepository.new(@config)
|
195
|
+
@segments_repository = SegmentsRepository.new(@config)
|
196
|
+
@impressions_repository = ImpressionsRepository.new(@config)
|
197
|
+
@events_repository = EventsRepository.new(@config, @api_key, @runtime_producer)
|
198
|
+
end
|
199
|
+
|
200
|
+
def build_telemetry_synchronizer
|
201
|
+
telemetry_api = Api::TelemetryApi.new(@config, @api_key, @runtime_producer)
|
202
|
+
@telemetry_synchronizer = Telemetry::Synchronizer.new(@config, @telemetry_consumers, @init_producer, repositories, telemetry_api)
|
203
|
+
end
|
204
|
+
|
205
|
+
def build_impressions_components
|
206
|
+
@impression_counter = Engine::Common::ImpressionCounter.new
|
207
|
+
@impressions_manager = Engine::Common::ImpressionManager.new(@config, @impressions_repository, @impression_counter, @runtime_producer)
|
208
|
+
end
|
170
209
|
end
|
171
210
|
end
|
@@ -13,29 +13,28 @@ module SplitIoClient
|
|
13
13
|
KEEP_ALIVE_RESPONSE = "c\r\n:keepalive\n\n\r\n".freeze
|
14
14
|
ERROR_EVENT_TYPE = 'error'.freeze
|
15
15
|
|
16
|
-
def initialize(config,
|
16
|
+
def initialize(config,
|
17
|
+
api_key,
|
18
|
+
telemetry_runtime_producer,
|
19
|
+
event_parser,
|
20
|
+
notification_manager_keeper,
|
21
|
+
notification_processor,
|
22
|
+
status_queue,
|
23
|
+
read_timeout: DEFAULT_READ_TIMEOUT)
|
17
24
|
@config = config
|
25
|
+
@api_key = api_key
|
26
|
+
@telemetry_runtime_producer = telemetry_runtime_producer
|
27
|
+
@event_parser = event_parser
|
28
|
+
@notification_manager_keeper = notification_manager_keeper
|
29
|
+
@notification_processor = notification_processor
|
30
|
+
@status_queue = status_queue
|
18
31
|
@read_timeout = read_timeout
|
19
32
|
@connected = Concurrent::AtomicBoolean.new(false)
|
20
33
|
@first_event = Concurrent::AtomicBoolean.new(true)
|
21
34
|
@socket = nil
|
22
|
-
@event_parser = SSE::EventSource::EventParser.new(config)
|
23
|
-
@on = { event: ->(_) {}, action: ->(_) {} }
|
24
|
-
@api_key = api_key
|
25
|
-
@telemetry_runtime_producer = telemetry_runtime_producer
|
26
|
-
|
27
|
-
yield self if block_given?
|
28
|
-
end
|
29
|
-
|
30
|
-
def on_event(&action)
|
31
|
-
@on[:event] = action
|
32
|
-
end
|
33
|
-
|
34
|
-
def on_action(&action)
|
35
|
-
@on[:action] = action
|
36
35
|
end
|
37
36
|
|
38
|
-
def close(
|
37
|
+
def close(status = nil)
|
39
38
|
unless connected?
|
40
39
|
@config.logger.error('SSEClient already disconected.') if @config.debug_enabled
|
41
40
|
return
|
@@ -43,7 +42,7 @@ module SplitIoClient
|
|
43
42
|
|
44
43
|
@connected.make_false
|
45
44
|
@socket&.close
|
46
|
-
|
45
|
+
push_status(status)
|
47
46
|
rescue StandardError => e
|
48
47
|
@config.logger.error("SSEClient close Error: #{e.inspect}")
|
49
48
|
end
|
@@ -76,8 +75,8 @@ module SplitIoClient
|
|
76
75
|
def connect_thread(latch)
|
77
76
|
@config.threads[:connect_stream] = Thread.new do
|
78
77
|
@config.logger.info('Starting connect_stream thread ...') if @config.debug_enabled
|
79
|
-
|
80
|
-
|
78
|
+
new_status = connect_stream(latch)
|
79
|
+
push_status(new_status)
|
81
80
|
@config.logger.info('connect_stream thread finished.') if @config.debug_enabled
|
82
81
|
end
|
83
82
|
end
|
@@ -132,7 +131,7 @@ module SplitIoClient
|
|
132
131
|
if response_code == OK_CODE && !error_event
|
133
132
|
@connected.make_true
|
134
133
|
@telemetry_runtime_producer.record_streaming_event(Telemetry::Domain::Constants::SSE_CONNECTION_ESTABLISHED, nil)
|
135
|
-
|
134
|
+
push_status(Constants::PUSH_CONNECTED)
|
136
135
|
end
|
137
136
|
|
138
137
|
latch.count_down
|
@@ -188,15 +187,18 @@ module SplitIoClient
|
|
188
187
|
end
|
189
188
|
|
190
189
|
def dispatch_event(event)
|
191
|
-
|
192
|
-
|
190
|
+
if event.occupancy?
|
191
|
+
@notification_manager_keeper.handle_incoming_occupancy_event(event)
|
192
|
+
else
|
193
|
+
@notification_processor.process(event)
|
194
|
+
end
|
193
195
|
end
|
194
196
|
|
195
|
-
def
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
197
|
+
def push_status(status)
|
198
|
+
return if status.nil?
|
199
|
+
|
200
|
+
@config.logger.debug("Pushing new sse status: #{status}")
|
201
|
+
@status_queue.push(status)
|
200
202
|
end
|
201
203
|
end
|
202
204
|
end
|
@@ -9,15 +9,13 @@ module SplitIoClient
|
|
9
9
|
ENABLED = 1
|
10
10
|
PAUSED = 2
|
11
11
|
|
12
|
-
def initialize(config, telemetry_runtime_producer)
|
12
|
+
def initialize(config, telemetry_runtime_producer, status_queue)
|
13
13
|
@config = config
|
14
|
+
@telemetry_runtime_producer = telemetry_runtime_producer
|
15
|
+
@status_queue = status_queue
|
14
16
|
@publisher_available = Concurrent::AtomicBoolean.new(true)
|
15
17
|
@publishers_pri = Concurrent::AtomicFixnum.new
|
16
18
|
@publishers_sec = Concurrent::AtomicFixnum.new
|
17
|
-
@on = { action: ->(_) {} }
|
18
|
-
@telemetry_runtime_producer = telemetry_runtime_producer
|
19
|
-
|
20
|
-
yield self if block_given?
|
21
19
|
end
|
22
20
|
|
23
21
|
def handle_incoming_occupancy_event(event)
|
@@ -27,27 +25,22 @@ module SplitIoClient
|
|
27
25
|
process_event_occupancy(event.channel, event.data['metrics']['publishers'])
|
28
26
|
end
|
29
27
|
rescue StandardError => e
|
30
|
-
p e
|
31
28
|
@config.logger.error(e)
|
32
29
|
end
|
33
30
|
|
34
|
-
def on_action(&action)
|
35
|
-
@on[:action] = action
|
36
|
-
end
|
37
|
-
|
38
31
|
private
|
39
32
|
|
40
33
|
def process_event_control(type)
|
41
34
|
case type
|
42
35
|
when 'STREAMING_PAUSED'
|
43
36
|
@telemetry_runtime_producer.record_streaming_event(Telemetry::Domain::Constants::STREAMING_STATUS, PAUSED)
|
44
|
-
|
37
|
+
push_status(Constants::PUSH_SUBSYSTEM_DOWN)
|
45
38
|
when 'STREAMING_RESUMED'
|
46
39
|
@telemetry_runtime_producer.record_streaming_event(Telemetry::Domain::Constants::STREAMING_STATUS, ENABLED)
|
47
|
-
|
40
|
+
push_status(Constants::PUSH_SUBSYSTEM_READY) if @publisher_available.value
|
48
41
|
when 'STREAMING_DISABLED'
|
49
42
|
@telemetry_runtime_producer.record_streaming_event(Telemetry::Domain::Constants::STREAMING_STATUS, DISABLED)
|
50
|
-
|
43
|
+
push_status(Constants::PUSH_SUBSYSTEM_OFF)
|
51
44
|
else
|
52
45
|
@config.logger.error("Incorrect event type: #{incoming_notification}")
|
53
46
|
end
|
@@ -60,10 +53,10 @@ module SplitIoClient
|
|
60
53
|
|
61
54
|
if !are_publishers_available? && @publisher_available.value
|
62
55
|
@publisher_available.make_false
|
63
|
-
|
56
|
+
push_status(Constants::PUSH_SUBSYSTEM_DOWN)
|
64
57
|
elsif are_publishers_available? && !@publisher_available.value
|
65
58
|
@publisher_available.make_true
|
66
|
-
|
59
|
+
push_status(Constants::PUSH_SUBSYSTEM_READY)
|
67
60
|
end
|
68
61
|
end
|
69
62
|
|
@@ -81,9 +74,9 @@ module SplitIoClient
|
|
81
74
|
@publishers_pri.value.positive? || @publishers_sec.value.positive?
|
82
75
|
end
|
83
76
|
|
84
|
-
def
|
85
|
-
@config.logger.debug("
|
86
|
-
@
|
77
|
+
def push_status(status)
|
78
|
+
@config.logger.debug("Pushing occupancy status: #{status}")
|
79
|
+
@status_queue.push(status)
|
87
80
|
end
|
88
81
|
end
|
89
82
|
end
|
@@ -5,33 +5,22 @@ module SplitIoClient
|
|
5
5
|
class SSEHandler
|
6
6
|
attr_reader :sse_client
|
7
7
|
|
8
|
-
def initialize(
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
@
|
14
|
-
@
|
15
|
-
@
|
16
|
-
@segments_worker = SplitIoClient::SSE::Workers::SegmentsWorker.new(synchronizer, @config, repositories[:segments])
|
17
|
-
@notification_processor = SplitIoClient::SSE::NotificationProcessor.new(@config, @splits_worker, @segments_worker)
|
18
|
-
@sse_client = SSE::EventSource::Client.new(@config, metadata[:api_key], telemetry_runtime_producer) do |client|
|
19
|
-
client.on_event { |event| handle_incoming_message(event) }
|
20
|
-
client.on_action { |action| process_action(action) }
|
21
|
-
end
|
22
|
-
|
23
|
-
@on = { action: ->(_) {} }
|
24
|
-
|
25
|
-
yield self if block_given?
|
8
|
+
def initialize(config,
|
9
|
+
splits_worker,
|
10
|
+
segments_worker,
|
11
|
+
sse_client)
|
12
|
+
@config = config
|
13
|
+
@splits_worker = splits_worker
|
14
|
+
@segments_worker = segments_worker
|
15
|
+
@sse_client = sse_client
|
26
16
|
end
|
27
17
|
|
28
18
|
def start(token_jwt, channels)
|
29
|
-
|
30
|
-
@sse_client.start(url)
|
19
|
+
@sse_client.start("#{@config.streaming_service_url}?channels=#{channels}&v=1.1&accessToken=#{token_jwt}")
|
31
20
|
end
|
32
21
|
|
33
22
|
def stop
|
34
|
-
@sse_client.close(Constants::
|
23
|
+
@sse_client.close(Constants::PUSH_FORCED_STOP)
|
35
24
|
stop_workers
|
36
25
|
rescue StandardError => e
|
37
26
|
@config.logger.debug("SSEHandler stop error: #{e.inspect}") if @config.debug_enabled
|
@@ -50,24 +39,6 @@ module SplitIoClient
|
|
50
39
|
@splits_worker.stop
|
51
40
|
@segments_worker.stop
|
52
41
|
end
|
53
|
-
|
54
|
-
def on_action(&action)
|
55
|
-
@on[:action] = action
|
56
|
-
end
|
57
|
-
|
58
|
-
private
|
59
|
-
|
60
|
-
def process_action(action)
|
61
|
-
@on[:action].call(action)
|
62
|
-
end
|
63
|
-
|
64
|
-
def handle_incoming_message(notification)
|
65
|
-
if notification.occupancy?
|
66
|
-
@notification_manager_keeper.handle_incoming_occupancy_event(notification)
|
67
|
-
else
|
68
|
-
@notification_processor.process(notification)
|
69
|
-
end
|
70
|
-
end
|
71
42
|
end
|
72
43
|
end
|
73
44
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: splitclient-rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 7.3.
|
4
|
+
version: 7.3.4.pre.rc1
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- Split Software
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-02-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|