splitclient-rb 7.1.0.pre.rc6-java → 7.1.0.pre.rc7-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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ac1d4034e91f02d4d45f2c08494de6aa9610f73d
4
- data.tar.gz: 7451b0307ff2d69d1a105529b447cf88dd181db4
3
+ metadata.gz: b2f25e3fbd1430c1ff7d74723cf941e2cc9ed86f
4
+ data.tar.gz: ba80d8b58f44a6ca5538f2e4925f4eb160a450b2
5
5
  SHA512:
6
- metadata.gz: 46324be3ee7d9b518f0149e2b4c9361d6d38f57827ff5b354a8558efb4bcbbc71125d97409fcc15ad04d87bbeab85c2eb7dd8eec2fd57c8750e035b11fd1e11d
7
- data.tar.gz: cbb1818d6246677debaccb87aa2ef02f830bd537f0d96cd36940211957a769de998d6567d50ff9dad7e6c70c825fc6f98469fab57d7d1e3e620ef9a2007f4591
6
+ metadata.gz: f7e168744f18e0851662fa560ffc18b1bcfb07b6a214794e114323334d306fc05821235f348610e63d4defafc26c62dd78dcd375acf22712f4f3f856aa918512
7
+ data.tar.gz: b38c2181655eed58de5baf76c7e1f091fe13cc83af8576d25173d8eccc2076fcb66ad240cba8ced8bee761d546c04c1f72c171cf90e445194c2158266708ebb7
@@ -37,10 +37,16 @@ module SplitIoClient
37
37
 
38
38
  def schedule_next_token_refresh(time)
39
39
  @config.threads[:schedule_next_token_refresh] = Thread.new do
40
- @config.logger.debug("schedule_next_token_refresh refresh in #{time} seconds.") if @config.debug_enabled
41
- sleep(time)
42
- stop_sse
43
- start_sse
40
+ begin
41
+ @config.logger.debug("schedule_next_token_refresh refresh in #{time} seconds.") if @config.debug_enabled
42
+ sleep(time)
43
+ @config.logger.debug('schedule_next_token_refresh starting ...') if @config.debug_enabled
44
+ stop_sse
45
+ sleep(1)
46
+ start_sse
47
+ rescue StandardError => e
48
+ @config.logger.debug("schedule_next_token_refresh error: #{e.inspect}") if @config.debug_enabled
49
+ end
44
50
  end
45
51
  end
46
52
  end
@@ -7,7 +7,7 @@ module SplitIoClient
7
7
  thread = config.threads[thread_sym]
8
8
 
9
9
  unless thread.nil?
10
- config.logger.debug("Stopping #{thread_sym} ...") if config.debug_enabled
10
+ config.logger.debug("Stopping #{thread_sym} thread...") if config.debug_enabled
11
11
  sleep(0.1) while thread.status == 'run'
12
12
  Thread.kill(thread)
13
13
  end
@@ -11,8 +11,7 @@ module SplitIoClient
11
11
  DEFAULT_READ_TIMEOUT = 70
12
12
  KEEP_ALIVE_RESPONSE = "c\r\n:keepalive\n\n\r\n".freeze
13
13
 
14
- def initialize(url, config, read_timeout: DEFAULT_READ_TIMEOUT)
15
- @uri = URI(url)
14
+ def initialize(config, read_timeout: DEFAULT_READ_TIMEOUT)
16
15
  @config = config
17
16
  @read_timeout = read_timeout
18
17
  @connected = Concurrent::AtomicBoolean.new(false)
@@ -22,9 +21,6 @@ module SplitIoClient
22
21
  @on = { event: ->(_) {}, connected: ->(_) {}, disconnect: ->(_) {} }
23
22
 
24
23
  yield self if block_given?
25
-
26
- connect_thread
27
- connect_passenger_forked if defined?(PhusionPassenger)
28
24
  end
29
25
 
30
26
  def on_event(&action)
@@ -42,8 +38,17 @@ module SplitIoClient
42
38
  def close
43
39
  dispatch_disconnect
44
40
  @connected.make_false
41
+ SplitIoClient::Helpers::ThreadHelper.stop(:connect_stream, @config)
45
42
  @socket&.close
46
43
  @socket = nil
44
+ @config.threads[:connect_stream] = nil
45
+ end
46
+
47
+ def start(url)
48
+ @uri = URI(url)
49
+
50
+ connect_thread
51
+ connect_passenger_forked if defined?(PhusionPassenger)
47
52
  end
48
53
 
49
54
  def connected?
@@ -53,7 +58,10 @@ module SplitIoClient
53
58
  private
54
59
 
55
60
  def connect_thread
56
- @config.threads[:connect_stream] = Thread.new { connect_stream }
61
+ @config.threads[:connect_stream] = Thread.new do
62
+ @config.logger.info('Starting connect_stream thread ...') if @config.debug_enabled
63
+ connect_stream
64
+ end
57
65
  end
58
66
 
59
67
  def connect_passenger_forked
@@ -70,17 +78,13 @@ module SplitIoClient
70
78
 
71
79
  while @connected.value
72
80
  begin
73
- partial_data = @socket.readpartial(10000, timeout: @read_timeout)
74
- rescue Socketry::TimeoutError
75
- @config.logger.error("Socket read time out in #{@read_timeout} seconds") if @config.debug_enabled
81
+ partial_data = @socket.readpartial(10_000, timeout: @read_timeout)
82
+ rescue StandardError => e
83
+ @config.logger.error(e.inspect) if @config.debug_enabled
76
84
  @connected.make_false
77
85
  @socket&.close
78
86
  @socket = nil
79
87
  connect_stream
80
- rescue StandardError => e
81
- @config.logger.error(e.inspect)
82
- close
83
- connect_stream
84
88
  end
85
89
 
86
90
  process_data(partial_data)
@@ -148,7 +152,7 @@ module SplitIoClient
148
152
 
149
153
  events
150
154
  rescue StandardError => e
151
- @config.logger.debug(buffer)
155
+ @config.logger.error(buffer)
152
156
  @config.logger.error("Error during parsing a event: #{e.inspect}")
153
157
  []
154
158
  end
@@ -11,6 +11,11 @@ module SplitIoClient
11
11
  @splits_worker = SplitIoClient::SSE::Workers::SplitsWorker.new(synchronizer, config, splits_repository)
12
12
  @segments_worker = SplitIoClient::SSE::Workers::SegmentsWorker.new(synchronizer, config, segments_repository)
13
13
  @notification_processor = SplitIoClient::SSE::NotificationProcessor.new(config, @splits_worker, @segments_worker)
14
+ @sse_client = SSE::EventSource::Client.new(@config) do |client|
15
+ client.on_event { |event| handle_incoming_message(event) }
16
+ client.on_connected { process_connected }
17
+ client.on_disconnect { process_disconnect }
18
+ end
14
19
 
15
20
  @on = { connected: ->(_) {}, disconnect: ->(_) {} }
16
21
 
@@ -19,17 +24,14 @@ module SplitIoClient
19
24
 
20
25
  def start(token_jwt, channels)
21
26
  url = "#{@config.streaming_service_url}?channels=#{channels}&v=1.1&accessToken=#{token_jwt}"
22
-
23
- @sse_client = SSE::EventSource::Client.new(url, @config) do |client|
24
- client.on_event { |event| handle_incoming_message(event) }
25
- client.on_connected { process_connected }
26
- client.on_disconnect { process_disconnect }
27
- end
27
+ @sse_client.start(url)
28
28
  end
29
29
 
30
30
  def stop
31
- @sse_client&.close
32
- @sse_client = nil
31
+ @sse_client.close
32
+ stop_workers
33
+ rescue StandardError => e
34
+ @config.logger.debug("SSEHandler stop error: #{e.inspect}") if @config.debug_enabled
33
35
  end
34
36
 
35
37
  def connected?
@@ -1,3 +1,3 @@
1
1
  module SplitIoClient
2
- VERSION = '7.1.0.pre.rc6'
2
+ VERSION = '7.1.0.pre.rc7'
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.rc6
4
+ version: 7.1.0.pre.rc7
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-23 00:00:00.000000000 Z
11
+ date: 2020-04-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement