splitclient-rb 7.1.0.pre.rc6 → 7.1.0.pre.rc7
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d5eb756de4960f089df823c0fa7c554ce7e8a7ce2fc44dc18b0d7bf56a666ea1
|
4
|
+
data.tar.gz: '09f7a93cff4759f75ce467ac1d7e3853142397c4c840de46509335bd3110a3f3'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fa93b0737066384f8e2e49bab166f8b23057578b6f1b940c9a27ff64cbcada99b3a982cbb6d43f78268d820189064c0b554761b84c3b198596eff6d0fc92fa20
|
7
|
+
data.tar.gz: 6dcac7c1907c25d322a004a290682e383cdc2f3e6880d25b2df5731a89beba7900ef0404eaffee895e6bbe3618315e32fe8bba0c14796f64ca96073088e0b773
|
@@ -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
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
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(
|
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
|
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(
|
74
|
-
rescue
|
75
|
-
@config.logger.error(
|
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.
|
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
|
32
|
-
|
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?
|
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.
|
4
|
+
version: 7.1.0.pre.rc7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Split Software
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-04-
|
11
|
+
date: 2020-04-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: allocation_stats
|