splitclient-rb 7.1.0.pre.rc3-java → 7.1.0.pre.rc4-java

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
  SHA1:
3
- metadata.gz: 1c75816a4a2e0708abbf38abc2c72924c6d1068c
4
- data.tar.gz: dab65344398758a3fea78f2bb6b77f3370d5503e
3
+ metadata.gz: 3773978239a090c92def574c430f8b4fae75b8aa
4
+ data.tar.gz: ddf8b97ce2c9b5f429a2e69d0b20545067a59e3e
5
5
  SHA512:
6
- metadata.gz: b388ef6f01412098f6931b0ea926eaf11bece7a9cb39ea2debee3a392b91c275e7657e22a12c3fd6c7f75db481a3a464217f17e12ea69f5383bf55da4ecc9a88
7
- data.tar.gz: 7fe83812cea04eb70909eeb282be4030ccf45894d8bff68e7470c95c249ec45beceb9cb4add420243cc062d05772e39ce885b780a45324170008d4204fc5057f
6
+ metadata.gz: 0fedca3dbb628ca64f46f72b516e7ab8add756746b10bf95de2579b2f007f700e5c4c8db7c2a326034b2ccc528fb4cdf3274543301167cad9b7f0c2bcbc4f9b6
7
+ data.tar.gz: a2ea5d71f11ddef491e89b168b837ebe3a692f83b6664ba7dee913f036b13b7947bcc821d1f8f9c266fddecdeb999801d131d711acbde6c10a14a851cb1eb8ff
@@ -14,6 +14,7 @@ Metrics/LineLength:
14
14
  Max: 130
15
15
  Exclude:
16
16
  - spec/sse/**/*
17
+ - spec/integrations/**/*
17
18
 
18
19
  Metrics/BlockLength:
19
20
  Exclude:
@@ -10,6 +10,7 @@ module SplitIoClient
10
10
  @metrics = metrics
11
11
  @config = config
12
12
  @sdk_blocker = sdk_blocker
13
+ @semaphore = Mutex.new
13
14
  end
14
15
 
15
16
  def call
@@ -27,15 +28,17 @@ module SplitIoClient
27
28
  end
28
29
 
29
30
  def fetch_segment(name)
30
- segments_api.fetch_segments_by_names([name])
31
+ @semaphore.synchronize { segments_api.fetch_segments_by_names([name]) }
31
32
  rescue StandardError => error
32
33
  @config.log_found_exception(__method__.to_s, error)
33
34
  end
34
35
 
35
36
  def fetch_segments
36
- segments_api.fetch_segments_by_names(@segments_repository.used_segment_names)
37
+ @semaphore.synchronize do
38
+ segments_api.fetch_segments_by_names(@segments_repository.used_segment_names)
37
39
 
38
- @sdk_blocker.segments_ready!
40
+ @sdk_blocker.segments_ready!
41
+ end
39
42
  rescue StandardError => error
40
43
  @config.log_found_exception(__method__.to_s, error)
41
44
  end
@@ -10,6 +10,7 @@ module SplitIoClient
10
10
  @metrics = metrics
11
11
  @config = config
12
12
  @sdk_blocker = sdk_blocker
13
+ @semaphore = Mutex.new
13
14
  end
14
15
 
15
16
  def call
@@ -27,18 +28,20 @@ module SplitIoClient
27
28
  end
28
29
 
29
30
  def fetch_splits
30
- data = splits_since(@splits_repository.get_change_number)
31
+ @semaphore.synchronize do
32
+ data = splits_since(@splits_repository.get_change_number)
31
33
 
32
- data[:splits] && data[:splits].each do |split|
33
- add_split_unless_archived(split)
34
- end
34
+ data[:splits] && data[:splits].each do |split|
35
+ add_split_unless_archived(split)
36
+ end
35
37
 
36
- @splits_repository.set_segment_names(data[:segment_names])
37
- @splits_repository.set_change_number(data[:till])
38
+ @splits_repository.set_segment_names(data[:segment_names])
39
+ @splits_repository.set_change_number(data[:till])
38
40
 
39
- @config.logger.debug("segments seen(#{data[:segment_names].length}): #{data[:segment_names].to_a}") if @config.debug_enabled
41
+ @config.logger.debug("segments seen(#{data[:segment_names].length}): #{data[:segment_names].to_a}") if @config.debug_enabled
40
42
 
41
- @sdk_blocker.splits_ready!
43
+ @sdk_blocker.splits_ready!
44
+ end
42
45
  rescue StandardError => error
43
46
  @config.log_found_exception(__method__.to_s, error)
44
47
  end
@@ -14,6 +14,7 @@ module SplitIoClient
14
14
  def start_sse
15
15
  response = @auth_api_client.authenticate(@api_key)
16
16
 
17
+ @config.logger.debug("Auth service response push_enabled: #{response[:push_enabled]}")
17
18
  if response[:push_enabled]
18
19
  @sse_handler.start(response[:token], response[:channels])
19
20
  schedule_next_token_refresh(response[:exp])
@@ -19,6 +19,7 @@ module SplitIoClient
19
19
  @synchronizer = Synchronizer.new(repositories, api_key, config, sdk_blocker, sync_params)
20
20
  notification_manager_keeper = SplitIoClient::SSE::NotificationManagerKeeper.new(config) do |manager|
21
21
  manager.on_occupancy { |publisher_available| process_occupancy(publisher_available) }
22
+ manager.on_push_shutdown { process_push_shutdown }
22
23
  end
23
24
  @sse_handler = SplitIoClient::SSE::SSEHandler.new(
24
25
  config,
@@ -57,8 +58,8 @@ module SplitIoClient
57
58
  def start_poll
58
59
  @synchronizer.start_periodic_fetch
59
60
  @synchronizer.start_periodic_data_recording
60
- rescue StandardError => error
61
- @config.logger.error(error)
61
+ rescue StandardError => e
62
+ @config.logger.error(e)
62
63
  end
63
64
 
64
65
  # Starts thread which fetch splits and segments once and trigger task to periodic data recording.
@@ -67,8 +68,8 @@ module SplitIoClient
67
68
  begin
68
69
  @synchronizer.sync_all
69
70
  @synchronizer.start_periodic_data_recording
70
- rescue StandardError => error
71
- @config.logger.error(error)
71
+ rescue StandardError => e
72
+ @config.logger.error(e)
72
73
  end
73
74
  end
74
75
  end
@@ -78,8 +79,8 @@ module SplitIoClient
78
79
  @config.threads[:sync_manager_start_sse] = Thread.new do
79
80
  begin
80
81
  @push_manager.start_sse
81
- rescue StandardError => error
82
- @config.logger.error(error)
82
+ rescue StandardError => e
83
+ @config.logger.error(e)
83
84
  end
84
85
  end
85
86
  end
@@ -103,9 +104,17 @@ module SplitIoClient
103
104
  @synchronizer.start_periodic_fetch
104
105
  end
105
106
 
106
- def process_occupancy(publisher_available)
107
- process_disconnect unless publisher_available
108
- process_connected if publisher_available
107
+ def process_occupancy(push_enable)
108
+ process_disconnect unless push_enable
109
+ process_connected if push_enable
110
+ end
111
+
112
+ def process_push_shutdown
113
+ @sse_handler.stop_workers
114
+ @push_manager.stop_sse
115
+ start_poll
116
+ rescue StandardError => e
117
+ @config.logger.error(e)
109
118
  end
110
119
  end
111
120
  end
@@ -7,14 +7,18 @@ module SplitIoClient
7
7
  class NotificationManagerKeeper
8
8
  def initialize(config)
9
9
  @config = config
10
- @polling_on = Concurrent::AtomicBoolean.new(false)
11
- @on = { occupancy: ->(_) {} }
10
+ @publisher_available = Concurrent::AtomicBoolean.new(true)
11
+ @on = { occupancy: ->(_) {}, push_shutdown: ->(_) {} }
12
12
 
13
13
  yield self if block_given?
14
14
  end
15
15
 
16
16
  def handle_incoming_occupancy_event(event)
17
- process_event(event.data['metrics']['publishers']) if event.channel == SplitIoClient::Constants::CONTROL_PRI
17
+ if event.data['type'] == 'CONTROL'
18
+ process_event_control(event.data['controlType'])
19
+ elsif event.channel == SplitIoClient::Constants::CONTROL_PRI
20
+ process_event_occupancy(event.data['metrics']['publishers'])
21
+ end
18
22
  rescue StandardError => e
19
23
  @config.logger.error(e)
20
24
  end
@@ -23,22 +27,46 @@ module SplitIoClient
23
27
  @on[:occupancy] = action
24
28
  end
25
29
 
30
+ def on_push_shutdown(&action)
31
+ @on[:push_shutdown] = action
32
+ end
33
+
26
34
  private
27
35
 
28
- def process_event(publishers)
29
- @config.logger.debug("Occupancy process event with #{publishers} publishers and polling on: #{@polling_on.value}")
30
- if publishers <= 0 && !@polling_on.value
31
- @polling_on.make_true
36
+ def process_event_control(type)
37
+ case type
38
+ when 'STREAMING_PAUSED'
32
39
  dispatch_occupancy_event(false)
33
- elsif publishers >= 1 && @polling_on.value
34
- @polling_on.make_false
40
+ when 'STREAMING_RESUMED'
41
+ dispatch_occupancy_event(true) if @publisher_available.value
42
+ when 'STREAMING_DISABLED'
43
+ dispatch_push_shutdown
44
+ else
45
+ @config.logger.error("Incorrect event type: #{incoming_notification}")
46
+ end
47
+ end
48
+
49
+ def process_event_occupancy(publishers)
50
+ @config.logger.debug(
51
+ "Occupancy process event with #{publishers} publishers and polling on: #{@publisher_available.value}"
52
+ )
53
+ if publishers <= 0 && @publisher_available.value
54
+ @publisher_available.make_false
55
+ dispatch_occupancy_event(false)
56
+ elsif publishers >= 1 && !@publisher_available.value
57
+ @publisher_available.make_true
35
58
  dispatch_occupancy_event(true)
36
59
  end
37
60
  end
38
61
 
39
- def dispatch_occupancy_event(publisher_available)
40
- @config.logger.debug("Dispatching occupancy event with publisher avaliable: #{publisher_available}")
41
- @on[:occupancy].call(publisher_available)
62
+ def dispatch_occupancy_event(push_enable)
63
+ @config.logger.debug("Dispatching occupancy event with publisher avaliable: #{push_enable}")
64
+ @on[:occupancy].call(push_enable)
65
+ end
66
+
67
+ def dispatch_push_shutdown
68
+ @config.logger.debug('Dispatching push shutdown')
69
+ @on[:push_shutdown].call
42
70
  end
43
71
  end
44
72
  end
@@ -1,3 +1,3 @@
1
1
  module SplitIoClient
2
- VERSION = '7.1.0.pre.rc3'
2
+ VERSION = '7.1.0.pre.rc4'
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.1.0.pre.rc3
4
+ version: 7.1.0.pre.rc4
5
5
  platform: java
6
6
  authors:
7
7
  - Split Software
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-17 00:00:00.000000000 Z
11
+ date: 2020-04-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement