splitclient-rb 7.3.3.pre.rc18 → 7.3.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 463a9d41ab4651544984dc087f5800d6e86566a694c8ca0929c224c145bed839
4
- data.tar.gz: e8a870ca9198ff396ca9d5f621d86623acb08cc081ea145623c27f0b8571565d
3
+ metadata.gz: 23b9c717284c495997eb1a3808850bd25816c29a447f13147f51a0c60138187e
4
+ data.tar.gz: 5b438d7782da8fb3e67689161d5fb53083665a5e4703f1b5fe628718e3cde81d
5
5
  SHA512:
6
- metadata.gz: 17fcb827a161a709cc2b6cbda87ed645d076eae3cb77a004ca9044f951adbd6ad040b0452c2f9eedf986e35ed2107a5d5b6d89e498303d2301c3356ff2acdb38
7
- data.tar.gz: 106f1726837501774021c23cb5136354dd17ef7ed134eba49840c60d3a6f065f4d7d7243048f4a0ede51a98b98e79a63845267d4d656f5132a5d398295e70c25
6
+ metadata.gz: 8dfa68a91b4e0cff3090d96640494f8755515499699c882b073ebe292f6920386e39b1c0be1b24a52b581f74d7092faa3c9ad5bf33bdf8565e7576d3f2ff2669
7
+ data.tar.gz: 76c004e32ac5e215b7e45690a96e9f0b9a2735f1212004f76c4402e3fabcbab2891ad22aa4caba3b6fb8aa5270b9a397589851a4d576254e7b0d70d01e78b6b7
@@ -0,0 +1,45 @@
1
+ name: Update License Year
2
+
3
+ on:
4
+ schedule:
5
+ - cron: "0 3 1 1 *" # 03:00 AM on January 1
6
+
7
+ permissions:
8
+ contents: write
9
+ pull-requests: write
10
+
11
+ jobs:
12
+ test:
13
+ runs-on: ubuntu-latest
14
+ steps:
15
+ - name: Checkout
16
+ uses: actions/checkout@v2
17
+ with:
18
+ fetch-depth: 0
19
+
20
+ - name: Set Current year
21
+ run: "echo CURRENT=$(date +%Y) >> $GITHUB_ENV"
22
+
23
+ - name: Set Previous Year
24
+ run: "echo PREVIOUS=$(($CURRENT-1)) >> $GITHUB_ENV"
25
+
26
+ - name: Update LICENSE
27
+ uses: jacobtomlinson/gha-find-replace@v2
28
+ with:
29
+ find: ${{ env.PREVIOUS }}
30
+ replace: ${{ env.CURRENT }}
31
+ include: "LICENSE"
32
+ regex: false
33
+
34
+ - name: Commit files
35
+ run: |
36
+ git config user.name 'github-actions[bot]'
37
+ git config user.email 'github-actions[bot]@users.noreply.github.com'
38
+ git commit -m "Updated License Year" -a
39
+
40
+ - name: Create Pull Request
41
+ uses: peter-evans/create-pull-request@v3
42
+ with:
43
+ token: ${{ secrets.GITHUB_TOKEN }}
44
+ title: Update License Year
45
+ branch: update-license
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: 8
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,19 @@
1
1
  CHANGES
2
2
 
3
+ 7.3.4 (Feb 21, 2022)
4
+ - Updated streaming events architecture with a new queue logic.
5
+ - Fixed redis integration Pipelining command deprecation warning.
6
+
7
+ 7.3.3 (Jan 28, 2022)
8
+ - Fixed edge cases where the sdk lost streaming connection.
9
+ - Updated default auth service url to https://auth.split.io/api/v2/auth
10
+ - Updated dependencies:
11
+ - faraday to >= 0.8, < 2.0
12
+ - net-http-persistent to >= 2.9, < 5.0
13
+ - redis to >= 4.0.0, < 5.0
14
+ - socketry to >= 0.4, < 1.0
15
+ - thread_safe to ~> 0.3
16
+
3
17
  7.3.2 (Dec 10, 2021)
4
18
  - Updated the readiness flow to be more consistent with the other sdks and improve the readiness time.
5
19
  - Updated the name of telemety key latencies in Redis.
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright © 2021 Split Software, Inc.
1
+ Copyright © 2022 Split Software, Inc.
2
2
 
3
3
  Licensed under the Apache License, Version 2.0 (the "License");
4
4
  you may not use this file except in compliance with the License.
@@ -160,7 +160,7 @@ module SplitIoClient
160
160
  end
161
161
 
162
162
  def pipelined
163
- @redis.pipelined do
163
+ @redis.pipelined do |pipeline|
164
164
  yield
165
165
  end
166
166
  end
@@ -12,4 +12,5 @@ class SplitIoClient::Constants
12
12
  PUSH_SUBSYSTEM_DOWN = 'PUSH_SUBSYSTEM_DOWN'
13
13
  PUSH_SUBSYSTEM_READY = 'PUSH_SUBSYSTEM_READY'
14
14
  PUSH_SUBSYSTEM_OFF = 'PUSH_SUBSYSTEM_OFF'
15
+ PUSH_FORCED_STOP = 'PUSH_FORCED_STOP'
15
16
  end
@@ -6,35 +6,23 @@ module SplitIoClient
6
6
  SYNC_MODE_STREAMING = 0
7
7
  SYNC_MODE_POLLING = 1
8
8
 
9
- def initialize(
10
- repositories,
11
- api_key,
12
- config,
13
- synchronizer,
14
- telemetry_runtime_producer,
15
- telemetry_synchronizer,
16
- status_manager
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
- split_fetcher = SplitFetcher.new(@splits_repository, @api_key, config, @runtime_producer)
63
- segment_fetcher = SegmentFetcher.new(@segments_repository, @api_key, config, @runtime_producer)
64
- params = {
65
- split_fetcher: split_fetcher,
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
- synchronizer = SplitIoClient::Engine::Synchronizer.new(repositories, @api_key, @config, params)
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, api_key, telemetry_runtime_producer, read_timeout: DEFAULT_READ_TIMEOUT)
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(action = nil)
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
- dispatch_action(action) unless action.nil?
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
- action = connect_stream(latch)
80
- dispatch_action(action) unless action.nil?
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
- dispatch_action(Constants::PUSH_CONNECTED)
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
- @config.logger.debug("Dispatching event: #{event.event_type}, #{event.channel}") if @config.debug_enabled
192
- @on[:event].call(event)
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 dispatch_action(action)
196
- @config.threads[:dispatch_action] = Thread.new do
197
- @config.logger.debug("Dispatching action: #{action}") if @config.debug_enabled
198
- @on[:action].call(action)
199
- end
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
- dispatch_action(Constants::PUSH_SUBSYSTEM_DOWN)
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
- dispatch_action(Constants::PUSH_SUBSYSTEM_READY) if @publisher_available.value
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
- dispatch_action(Constants::PUSH_SUBSYSTEM_OFF)
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
- dispatch_action(Constants::PUSH_SUBSYSTEM_DOWN)
56
+ push_status(Constants::PUSH_SUBSYSTEM_DOWN)
64
57
  elsif are_publishers_available? && !@publisher_available.value
65
58
  @publisher_available.make_true
66
- dispatch_action(Constants::PUSH_SUBSYSTEM_READY)
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 dispatch_action(action)
85
- @config.logger.debug("Dispatching action: #{action}")
86
- @on[:action].call(action)
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(metadata,
9
- synchronizer,
10
- repositories,
11
- notification_manager_keeper,
12
- telemetry_runtime_producer)
13
- @config = metadata[:config]
14
- @notification_manager_keeper = notification_manager_keeper
15
- @splits_worker = SplitIoClient::SSE::Workers::SplitsWorker.new(synchronizer, @config, repositories[:splits])
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
- url = "#{@config.streaming_service_url}?channels=#{channels}&v=1.1&accessToken=#{token_jwt}"
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::PUSH_NONRETRYABLE_ERROR)
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
@@ -1,3 +1,3 @@
1
1
  module SplitIoClient
2
- VERSION = '7.3.3.pre.rc18'
2
+ VERSION = '7.3.4'
3
3
  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.3.pre.rc18
4
+ version: 7.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Split Software
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-01-26 00:00:00.000000000 Z
11
+ date: 2022-02-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: allocation_stats
@@ -364,6 +364,7 @@ extra_rdoc_files: []
364
364
  files:
365
365
  - ".github/pull_request_template.md"
366
366
  - ".github/workflows/ci.yml"
367
+ - ".github/workflows/update-license-year.yml"
367
368
  - ".gitignore"
368
369
  - ".rubocop.yml"
369
370
  - ".simplecov"
@@ -519,9 +520,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
519
520
  version: '0'
520
521
  required_rubygems_version: !ruby/object:Gem::Requirement
521
522
  requirements:
522
- - - ">"
523
+ - - ">="
523
524
  - !ruby/object:Gem::Version
524
- version: 1.3.1
525
+ version: '0'
525
526
  requirements: []
526
527
  rubygems_version: 3.2.32
527
528
  signing_key: