splitclient-rb 8.10.0.pre.rc4 → 8.10.0.pre.rc6
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 +4 -4
- data/lib/splitclient-rb/sse/event_source/client.rb +38 -47
- data/lib/splitclient-rb/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: fb5be51256d248db7f231bd39fafe653dd91d9c9a73d46f97430f2a3c9cf4f71
|
|
4
|
+
data.tar.gz: 693aaf493fa9d963af7a74773f0008921110c1f7f99c2175df194800c7bbc55b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ddc1a2958feba075b84660970e0db1e599e8c0cc2557885e0efadce9d0a0bd3f9defc73fd4330922bf539203a0a84f9ac5975f9b530e827e8877bc341ec86a80
|
|
7
|
+
data.tar.gz: f959c0a93d647e80804154c5882d3c1d87d7f339430c6c3f08fa4d890c6aaacffaa8dbcf2614dd81fde2c1f9bac3c34f28e4a440ae405262b0b011af1d6731de
|
|
@@ -38,7 +38,7 @@ module SplitIoClient
|
|
|
38
38
|
|
|
39
39
|
def close(status = nil)
|
|
40
40
|
unless connected?
|
|
41
|
-
|
|
41
|
+
@config.logger.debug('SSEClient already disconected.')
|
|
42
42
|
return
|
|
43
43
|
end
|
|
44
44
|
|
|
@@ -76,49 +76,54 @@ module SplitIoClient
|
|
|
76
76
|
|
|
77
77
|
def connect_thread(latch)
|
|
78
78
|
@config.threads[:connect_stream] = Thread.new do
|
|
79
|
-
|
|
79
|
+
@config.logger.info('Starting connect_stream thread ...')
|
|
80
80
|
new_status = connect_stream(latch)
|
|
81
81
|
push_status(new_status)
|
|
82
|
-
|
|
82
|
+
@config.logger.info('connect_stream thread finished.')
|
|
83
83
|
end
|
|
84
84
|
end
|
|
85
85
|
|
|
86
86
|
def connect_stream(latch)
|
|
87
87
|
return Constants::PUSH_NONRETRYABLE_ERROR unless socket_write(latch)
|
|
88
88
|
while connected? || @first_event.value
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
partial_data = ""
|
|
92
|
-
Timeout::timeout @read_timeout do
|
|
89
|
+
if IO.select([@socket], nil, nil, @read_timeout)
|
|
90
|
+
begin
|
|
93
91
|
partial_data = @socket.readpartial(10_000)
|
|
94
|
-
|
|
95
|
-
read_first_event(partial_data, latch)
|
|
92
|
+
read_first_event(partial_data, latch)
|
|
96
93
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
94
|
+
raise 'eof exception' if partial_data == :eof
|
|
95
|
+
rescue IO::WaitReadable => e
|
|
96
|
+
@config.logger.debug("SSE client IO::WaitReadable transient error: #{e.inspect}")
|
|
97
|
+
IO.select([@socket], nil, nil, @read_timeout)
|
|
98
|
+
retry
|
|
99
|
+
rescue Errno::EAGAIN => e
|
|
100
|
+
@config.logger.debug("SSE client transient error: #{e.inspect}")
|
|
101
|
+
IO.select([@socket], nil, nil, @read_timeout)
|
|
102
|
+
retry
|
|
103
|
+
rescue Errno::ETIMEDOUT => e
|
|
104
|
+
@config.logger.error("SSE read operation timed out!: #{e.inspect}")
|
|
105
|
+
return Constants::PUSH_RETRYABLE_ERROR
|
|
106
|
+
rescue EOFError => e
|
|
107
|
+
@config.logger.error("SSE read operation EOF Exception!: #{e.inspect}")
|
|
108
|
+
raise 'eof exception'
|
|
109
|
+
rescue Errno::EBADF, IOError => e
|
|
110
|
+
@config.logger.error("SSE read operation EBADF or IOError: #{e.inspect}")
|
|
111
|
+
return Constants::PUSH_RETRYABLE_ERROR
|
|
112
|
+
rescue StandardError => e
|
|
113
|
+
@config.logger.error("SSE read operation StandardError: #{e.inspect}")
|
|
114
|
+
return nil if ENV['SPLITCLIENT_ENV'] == 'test'
|
|
115
|
+
|
|
116
|
+
@config.logger.error("Error reading partial data: #{e.inspect}")
|
|
117
|
+
return Constants::PUSH_RETRYABLE_ERROR
|
|
118
|
+
end
|
|
119
|
+
else
|
|
120
|
+
@config.logger.error("SSE read operation timed out, no data available.")
|
|
116
121
|
return Constants::PUSH_RETRYABLE_ERROR
|
|
117
122
|
end
|
|
118
123
|
|
|
119
124
|
process_data(partial_data)
|
|
120
125
|
end
|
|
121
|
-
|
|
126
|
+
@config.logger.info("SSE read operation exited: #{connected?}")
|
|
122
127
|
|
|
123
128
|
nil
|
|
124
129
|
end
|
|
@@ -129,7 +134,7 @@ module SplitIoClient
|
|
|
129
134
|
@socket.puts(build_request(@uri))
|
|
130
135
|
true
|
|
131
136
|
rescue StandardError => e
|
|
132
|
-
|
|
137
|
+
@config.logger.error("Error during connecting to #{@uri.host}. Error: #{e.inspect}")
|
|
133
138
|
latch.count_down
|
|
134
139
|
false
|
|
135
140
|
end
|
|
@@ -172,9 +177,8 @@ module SplitIoClient
|
|
|
172
177
|
IO.select(nil, [ssl_socket])
|
|
173
178
|
retry
|
|
174
179
|
end
|
|
175
|
-
|
|
176
180
|
return ssl_socket
|
|
177
|
-
|
|
181
|
+
|
|
178
182
|
rescue Exception => e
|
|
179
183
|
@config.logger.error("socket connect error: #{e.inspect}")
|
|
180
184
|
return nil
|
|
@@ -185,7 +189,7 @@ module SplitIoClient
|
|
|
185
189
|
end
|
|
186
190
|
|
|
187
191
|
def process_data(partial_data)
|
|
188
|
-
|
|
192
|
+
@config.logger.debug("Event partial data: #{partial_data}")
|
|
189
193
|
return if partial_data.nil? || partial_data == KEEP_ALIVE_RESPONSE
|
|
190
194
|
|
|
191
195
|
events = @event_parser.parse(partial_data)
|
|
@@ -203,7 +207,7 @@ module SplitIoClient
|
|
|
203
207
|
req << "SplitSDKMachineName: #{@config.machine_name}\r\n"
|
|
204
208
|
req << "SplitSDKClientKey: #{@api_key.split(//).last(4).join}\r\n" unless @api_key.nil?
|
|
205
209
|
req << "Cache-Control: no-cache\r\n\r\n"
|
|
206
|
-
|
|
210
|
+
@config.logger.debug("Request info: #{req}")
|
|
207
211
|
req
|
|
208
212
|
end
|
|
209
213
|
|
|
@@ -241,19 +245,6 @@ module SplitIoClient
|
|
|
241
245
|
@config.logger.debug("Pushing new sse status: #{status}")
|
|
242
246
|
@status_queue.push(status)
|
|
243
247
|
end
|
|
244
|
-
|
|
245
|
-
def log_if_debug(text, level)
|
|
246
|
-
if @config.debug_enabled
|
|
247
|
-
case level
|
|
248
|
-
when 1
|
|
249
|
-
@config.logger.debug(text)
|
|
250
|
-
when 2
|
|
251
|
-
@config.logger.info(text)
|
|
252
|
-
else
|
|
253
|
-
@config.logger.error(text)
|
|
254
|
-
end
|
|
255
|
-
end
|
|
256
|
-
end
|
|
257
248
|
end
|
|
258
249
|
end
|
|
259
250
|
end
|