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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fb3dfc125b557830b44424f5d6a42dbf5ba16f823d7741910020083a3e755b95
4
- data.tar.gz: 940c7952301a2859e3d5f5c77b00587ec81015a2919f893aadd38adb73bad867
3
+ metadata.gz: fb5be51256d248db7f231bd39fafe653dd91d9c9a73d46f97430f2a3c9cf4f71
4
+ data.tar.gz: 693aaf493fa9d963af7a74773f0008921110c1f7f99c2175df194800c7bbc55b
5
5
  SHA512:
6
- metadata.gz: 26170c1a732d710b4894a8c72b4c84a4d056fb6aa960fdfb3c91c9e7171dcd27fdd407808d4bd9684a70c9896487cdec4b9d57b8c8a9d07952eaf0f44934adee
7
- data.tar.gz: 241aae97c4318d37d23284f4fb6cedc05f3991c49e4044048f8051c893177a6b0afecc80da393fa4b7d4e6037f5f09ba60e4a11381ab8d3ad2db2b653450828a
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
- log_if_debug('SSEClient already disconected.', 3)
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
- log_if_debug('Starting connect_stream thread ...', 2)
79
+ @config.logger.info('Starting connect_stream thread ...')
80
80
  new_status = connect_stream(latch)
81
81
  push_status(new_status)
82
- log_if_debug('connect_stream thread finished.', 2)
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
- log_if_debug("Inside coonnect_stream while loop.", 3)
90
- begin
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
- end
95
- read_first_event(partial_data, latch)
92
+ read_first_event(partial_data, latch)
96
93
 
97
- raise 'eof exception' if partial_data == :eof
98
- rescue Timeout::Error => e
99
- log_if_debug("SSE read operation timed out!: #{e.inspect}", 3)
100
- return Constants::PUSH_RETRYABLE_ERROR
101
- rescue EOFError => e
102
- log_if_debug("SSE read operation EOF Exception!: #{e.inspect}", 3)
103
- raise 'eof exception'
104
- rescue Errno::EAGAIN => e
105
- log_if_debug("SSE client transient error: #{e.inspect}", 1)
106
- IO.select([tcp_socket])
107
- retry
108
- rescue Errno::EBADF, IOError => e
109
- log_if_debug("SSE read operation EBADF or IOError: #{e.inspect}", 3)
110
- return nil
111
- rescue StandardError => e
112
- log_if_debug("SSE read operation StandardError: #{e.inspect}", 3)
113
- return nil if ENV['SPLITCLIENT_ENV'] == 'test'
114
-
115
- log_if_debug("Error reading partial data: #{e.inspect}", 3)
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
- log_if_debug("SSE read operation exited: #{connected?}", 3)
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
- log_if_debug("Error during connecting to #{@uri.host}. Error: #{e.inspect}", 3)
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
- # return ssl_socket.connect
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
- log_if_debug("Event partial data: #{partial_data}", 1)
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
- log_if_debug("Request info: #{req}", 1)
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
@@ -1,3 +1,3 @@
1
1
  module SplitIoClient
2
- VERSION = '8.10.0-rc4'
2
+ VERSION = '8.10.0-rc6'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: splitclient-rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.10.0.pre.rc4
4
+ version: 8.10.0.pre.rc6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Split Software