splitclient-rb 7.3.3.pre.rc9 → 7.3.3.pre.rc13

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: ec6fc8163dee8d303228ac119e0d704bd827b00c2a4dd6408cef7af1c7f35767
4
- data.tar.gz: 841be300c51ec06e5abc3b916ab69efeb42bfb15efc36179673dcefce7fd2165
3
+ metadata.gz: ea33a02d9d4529927792f590796263d2eb2985ef367183acdb3a8be92e92b518
4
+ data.tar.gz: d7fca9070abddd5347600d4be81411d253efcbfb3c42a3dd5a929c718aae6b08
5
5
  SHA512:
6
- metadata.gz: 2fa16a7e50e717f9f0af64d8159a586ca9ece0dcba1c4f56914f73064a07c2fe30edc70ce9460fab3e5cd9282885179a4a4479dcbc613e569c926e9c31d09b57
7
- data.tar.gz: b6e45d41dc353aeca5cb98f666814d57d9481cb8844fdd7170647dead43071a8fbe76d30a7ee45aceb8f4dd43c317bb5806dd20a4e538d64e7e888c0f50c0a81
6
+ metadata.gz: b565bb319c60aa4c6589d9480940fedf7ee46e44bf2f43062d4f887059d21be2330802e91a18d0acb094d8b9c8721f704318f1e934ed537c2d7cecbb326f1244
7
+ data.tar.gz: 28f349e55ab2067ba016115a5ee09f730b7c470c99fca4ec84ce00ad45ecb0caadbab8641ab504f05a8926040fc8e050c3a6b14df765cc77ace3f2de347b7314
@@ -18,7 +18,7 @@ module SplitIoClient
18
18
  @config.logger.debug("Auth service response push_enabled: #{response[:push_enabled]}") if @config.debug_enabled
19
19
 
20
20
  if response[:push_enabled] && @sse_handler.start(response[:token], response[:channels])
21
- schedule_next_token_refresh(response[:exp])
21
+ schedule_next_token_refresh(150)
22
22
  @back_off.reset
23
23
  record_telemetry(response[:exp])
24
24
 
@@ -34,8 +34,13 @@ module SplitIoClient
34
34
  end
35
35
 
36
36
  def stop_sse
37
+ @config.logger.error('## STOP SSE')
37
38
  @sse_handler.process_disconnect if @sse_handler.sse_client.nil?
38
39
  @sse_handler.stop
40
+ stop_next_token_refresh
41
+ end
42
+
43
+ def stop_next_token_refresh
39
44
  SplitIoClient::Helpers::ThreadHelper.stop(:schedule_next_token_refresh, @config)
40
45
  end
41
46
 
@@ -47,9 +52,12 @@ module SplitIoClient
47
52
  @config.logger.debug("schedule_next_token_refresh refresh in #{time} seconds.") if @config.debug_enabled
48
53
  sleep(time)
49
54
  @config.logger.debug('schedule_next_token_refresh starting ...') if @config.debug_enabled
55
+ @config.logger.error('## SCHEDULE NEXT TOKEN')
56
+
50
57
  @sse_handler.stop
51
58
  start_sse
52
59
  rescue StandardError => e
60
+ @config.logger.error("## SCHEDULE EXCEPTION #{e.inspect}")
53
61
  @config.logger.debug("schedule_next_token_refresh error: #{e.inspect}") if @config.debug_enabled
54
62
  end
55
63
  end
@@ -67,6 +67,7 @@ module SplitIoClient
67
67
  end
68
68
 
69
69
  def process_action(action)
70
+ @config.logger.error("process_action #{action}")
70
71
  case action
71
72
  when Constants::PUSH_CONNECTED
72
73
  process_connected
@@ -117,8 +118,8 @@ module SplitIoClient
117
118
 
118
119
  @sse_connected.make_true
119
120
  @synchronizer.stop_periodic_fetch
120
- @synchronizer.sync_all
121
121
  @sse_handler.start_workers
122
+ @synchronizer.sync_all
122
123
  record_telemetry(Telemetry::Domain::Constants::SYNC_MODE, SYNC_MODE_STREAMING)
123
124
  rescue StandardError => e
124
125
  @config.logger.error("process_connected error: #{e.inspect}")
@@ -131,11 +132,12 @@ module SplitIoClient
131
132
  end
132
133
 
133
134
  @sse_connected.make_false
134
- @sse_handler.stop_workers
135
135
  @synchronizer.start_periodic_fetch
136
+ @sse_handler.stop_workers
136
137
  record_telemetry(Telemetry::Domain::Constants::SYNC_MODE, SYNC_MODE_POLLING)
137
138
 
138
139
  if reconnect
140
+ @push_manager.stop_sse
139
141
  @synchronizer.sync_all
140
142
  @push_manager.start_sse
141
143
  end
@@ -7,9 +7,8 @@ module SplitIoClient
7
7
  thread = config.threads[thread_sym]
8
8
 
9
9
  unless thread.nil?
10
- config.logger.debug("Stopping #{thread_sym} thread...") if config.debug_enabled
11
- sleep(0.1) while thread.status == 'run'
12
- Thread.kill(thread)
10
+ Thread.kill thread
11
+ config.logger.debug("#{thread_sym} killed.") if config.debug_enabled
13
12
  end
14
13
  rescue StandardError => e
15
14
  config.logger.error(e.inspect)
@@ -35,11 +35,15 @@ module SplitIoClient
35
35
  @on[:action] = action
36
36
  end
37
37
 
38
- def close(action = Constants::PUSH_NONRETRYABLE_ERROR)
38
+ def close
39
+ unless connected?
40
+ @config.logger.error('SSEClient already disconected.') if @config.debug_enabled
41
+ return
42
+ end
43
+
39
44
  @connected.make_false
40
- SplitIoClient::Helpers::ThreadHelper.stop(:connect_stream, @config)
41
45
  @socket&.close
42
- dispatch_action(action)
46
+ @config.logger.error('## CLOSE SSE')
43
47
  rescue StandardError => e
44
48
  @config.logger.error("SSEClient close Error: #{e.inspect}")
45
49
  end
@@ -71,13 +75,17 @@ module SplitIoClient
71
75
 
72
76
  def connect_thread(latch)
73
77
  @config.threads[:connect_stream] = Thread.new do
78
+ @config.logger.error('## CONNECT THREAD')
74
79
  @config.logger.info('Starting connect_stream thread ...') if @config.debug_enabled
75
- connect_stream(latch)
80
+ closed_with_exception = connect_stream(latch)
81
+ dispatch_action(closed_with_exception) unless closed_with_exception.nil?
82
+ @config.logger.info('connect_stream thread finished.') if @config.debug_enabled
83
+ @config.logger.error('#### DISCONNECTED')
76
84
  end
77
85
  end
78
86
 
79
87
  def connect_stream(latch)
80
- socket_write(latch)
88
+ return Constants::PUSH_NONRETRYABLE_ERROR unless socket_write(latch)
81
89
 
82
90
  while connected? || @first_event.value
83
91
  begin
@@ -86,24 +94,28 @@ module SplitIoClient
86
94
  read_first_event(partial_data, latch)
87
95
 
88
96
  raise 'eof exception' if partial_data == :eof
97
+ rescue Errno::EBADF, IOError => e
98
+ @config.logger.error(e.inspect)
99
+ return nil
89
100
  rescue StandardError => e
90
- @config.logger.error('Error reading partial data: ' + e.inspect) if @config.debug_enabled
91
- close(Constants::PUSH_RETRYABLE_ERROR)
92
- return
101
+ @config.logger.error("Error reading partial data: #{e.inspect}") if @config.debug_enabled
102
+ return Constants::PUSH_RETRYABLE_ERROR
93
103
  end
94
104
 
95
105
  process_data(partial_data)
96
106
  end
107
+ nil
97
108
  end
98
109
 
99
110
  def socket_write(latch)
100
111
  @first_event.make_true
101
112
  @socket = socket_connect
102
113
  @socket.write(build_request(@uri))
114
+ true
103
115
  rescue StandardError => e
104
116
  @config.logger.error("Error during connecting to #{@uri.host}. Error: #{e.inspect}")
105
- close(Constants::PUSH_NONRETRYABLE_ERROR)
106
117
  latch.count_down
118
+ false
107
119
  end
108
120
 
109
121
  def read_first_event(data, latch)
@@ -181,8 +193,10 @@ module SplitIoClient
181
193
  end
182
194
 
183
195
  def dispatch_action(action)
184
- @config.logger.debug("Dispatching action: #{action}") if @config.debug_enabled
185
- @on[:action].call(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
186
200
  end
187
201
  end
188
202
  end
@@ -1,3 +1,3 @@
1
1
  module SplitIoClient
2
- VERSION = '7.3.3.pre.rc9'
2
+ VERSION = '7.3.3.pre.rc13'
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.rc9
4
+ version: 7.3.3.pre.rc13
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-20 00:00:00.000000000 Z
11
+ date: 2022-01-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: allocation_stats