splitclient-rb 7.2.3.pre.rc1 → 7.2.3.pre.rc2

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: f35241d91acb957b2e666ca2598021b66f8214d4d12980484b063723576dc13c
4
- data.tar.gz: 1a833d613162de2aa18a3c925de083ddc2013bfe85630d57b2e9483a8364c357
3
+ metadata.gz: 816703e29d94e1cd110cb01dfd74d4acaa8ba86b0c30306c4e54469e73d1ef42
4
+ data.tar.gz: be893e8e6c83976ddffcbbcd8cadee0c237ec8cbd8a346d3124213f54ab883d8
5
5
  SHA512:
6
- metadata.gz: 231f86643247585e51cbb136790d71011764645edb87383c5641730b4e36952c1013dde5c06fbb46002c05b1fa07579a0b8579a3a4e859cc42862d0d2849316c
7
- data.tar.gz: faff2962445b587f133d703ce19fec646a8495fbef7f34d8dd27d38614643bd517acf99d859b613220a4144c4f56be61c1ae048b526ef8e63a92134dfdcbda79
6
+ metadata.gz: 5924df50b100425b81950f8e7720752e73544dcfea0cda0f8e626075bc3998cf49e3ae1cc140288db247d5a6f5008f068e1f23a40a3335779e0003b70eab4a8c
7
+ data.tar.gz: 0d197320d80ececb3d7b1f70cdf2b1f1eae62ee77f7cb6887082070bcc16332ebf426f3c884c086cdcc9a70e85e4028b2fc1032cf45ae5f3ca89be62d408b1f5
@@ -27,14 +27,22 @@ module SplitIoClient
27
27
  end
28
28
  end
29
29
 
30
+ def fetch_segments_if_not_exists(names)
31
+ names.each do |name|
32
+ change_number = @segments_repository.get_change_number(name)
33
+
34
+ fetch_segment(name) if change_number == -1
35
+ end
36
+ rescue StandardError => error
37
+ @config.log_found_exception(__method__.to_s, error)
38
+ end
39
+
30
40
  def fetch_segment(name)
31
41
  @semaphore.synchronize do
32
42
  segments_api.fetch_segments_by_names([name])
33
- true
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
@@ -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
- true
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
@@ -13,4 +13,3 @@ class SplitIoClient::Constants
13
13
  PUSH_SUBSYSTEM_READY = 'PUSH_SUBSYSTEM_READY'
14
14
  PUSH_SUBSYSTEM_OFF = 'PUSH_SUBSYSTEM_OFF'
15
15
  end
16
-
@@ -30,7 +30,7 @@ module SplitIoClient
30
30
  def sync_all
31
31
  @config.threads[:sync_all_thread] = Thread.new do
32
32
  @config.logger.debug('Synchronizing Splits and Segments ...') if @config.debug_enabled
33
- fetch_splits
33
+ @split_fetcher.fetch_splits
34
34
  fetch_segments
35
35
  end
36
36
  end
@@ -53,21 +53,12 @@ module SplitIoClient
53
53
  end
54
54
 
55
55
  def fetch_splits
56
- back_off = SplitIoClient::SSE::EventSource::BackOff.new(SplitIoClient::Constants::FETCH_BACK_OFF_BASE_RETRIES, 1)
57
- loop do
58
- break if @split_fetcher.fetch_splits
59
-
60
- sleep(back_off.interval)
61
- end
56
+ segment_names = @split_fetcher.fetch_splits
57
+ @segment_fetcher.fetch_segments_if_not_exists(segment_names) unless segment_names.empty?
62
58
  end
63
59
 
64
60
  def fetch_segment(name)
65
- back_off = SplitIoClient::SSE::EventSource::BackOff.new(SplitIoClient::Constants::FETCH_BACK_OFF_BASE_RETRIES, 1)
66
- loop do
67
- break if @segment_fetcher.fetch_segment(name)
68
-
69
- sleep(back_off.interval)
70
- end
61
+ @segment_fetcher.fetch_segment(name)
71
62
  end
72
63
 
73
64
  private
@@ -43,6 +43,11 @@ module SplitIoClient
43
43
  end
44
44
 
45
45
  def start(url)
46
+ if connected?
47
+ @config.logger.debug('SSEClient already running.')
48
+ return true
49
+ end
50
+
46
51
  @uri = URI(url)
47
52
  latch = Concurrent::CountDownLatch.new(1)
48
53
 
@@ -48,12 +48,13 @@ module SplitIoClient
48
48
  def perform
49
49
  while (item = @queue.pop)
50
50
  segment_name = item[:segment_name]
51
- change_number = item[:change_number]
52
- since = @segments_repository.get_change_number(segment_name)
51
+ cn = item[:change_number]
52
+ @config.logger.debug("SegmentsWorker change_number dequeue #{segment_name}, #{cn}")
53
53
 
54
- unless since >= change_number
55
- @config.logger.debug("SegmentsWorker fetch_segment with #{since}")
54
+ attempt = 0
55
+ while cn > @segments_repository.get_change_number(segment_name).to_i && attempt <= Workers::MAX_RETRIES_ALLOWED
56
56
  @synchronizer.fetch_segment(segment_name)
57
+ attempt += 1
57
58
  end
58
59
  end
59
60
  end
@@ -3,6 +3,8 @@
3
3
  module SplitIoClient
4
4
  module SSE
5
5
  module Workers
6
+ MAX_RETRIES_ALLOWED = 10
7
+
6
8
  class SplitsWorker
7
9
  def initialize(synchronizer, config, splits_repository)
8
10
  @synchronizer = synchronizer
@@ -59,11 +61,12 @@ module SplitIoClient
59
61
 
60
62
  def perform
61
63
  while (change_number = @queue.pop)
62
- since = @splits_repository.get_change_number
64
+ @config.logger.debug("SplitsWorker change_number dequeue #{change_number}")
63
65
 
64
- unless since.to_i >= change_number
65
- @config.logger.debug("SplitsWorker fetch_splits with #{since}")
66
+ attempt = 0
67
+ while change_number > @splits_repository.get_change_number.to_i && attempt <= Workers::MAX_RETRIES_ALLOWED
66
68
  @synchronizer.fetch_splits
69
+ attempt += 1
67
70
  end
68
71
  end
69
72
  end
@@ -1,3 +1,3 @@
1
1
  module SplitIoClient
2
- VERSION = '7.2.3.pre.rc1'
2
+ VERSION = '7.2.3.pre.rc2'
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.2.3.pre.rc1
4
+ version: 7.2.3.pre.rc2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Split Software
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-01-20 00:00:00.000000000 Z
11
+ date: 2021-02-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: allocation_stats