splitclient-rb 8.9.0 → 8.10.0.pre.rc1

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: 6e9675cf0c10ae67ec9447508972333071c09ac6573b8c593d92ef0a6cd93897
4
- data.tar.gz: de84dd6e79108b69e27e387ff2e490b6ef50de23af3bbf7a7ef999308171dce5
3
+ metadata.gz: faa592693c5eec8dd63775a853a63c5c52e80a3c25d7af5f35a9d06d11417a36
4
+ data.tar.gz: 78c42358703b9d84ed3cf6cd00d730e0a95424b3fa75eb49fb48ec1ab64a93b4
5
5
  SHA512:
6
- metadata.gz: b32b6fb272ff79f489bbb41adeb8ebd1c763dbe14aeffdc63c90b9c60ac7973ff212c28ffdecdaf5e5fd6215c5a92d4217d57e55d41b1af16107f1aa1141d092
7
- data.tar.gz: f8f5d13d8ab366ee267fa48e2c0b7b342c5b8a36e69ad961e10c708eb188d00a870b23a3c027b60fabd0e898664601128b1064b1ca712cd99f03e5c42841afb8
6
+ metadata.gz: 9c0a801ba90efdece2caade58ab1b9e986b1e3bfeb17418a2402da5688dffcc46baaaedc30ed78552c46bec2acd0b39fc12223a095f2c9352fcc5e0ec9c8e37a
7
+ data.tar.gz: 4e840f649032451ff63d362d5e87757b1f7958741f99689a72b66ff764dd691a15ac222c4bdff86ae49fc10157f8e2c3c609d95fc95ac4aa9fc4b3d5cc53ccd9
@@ -1,7 +1,9 @@
1
1
  # frozen_string_literal: false
2
2
 
3
- require 'socketry'
3
+ require 'socket'
4
+ require 'openssl'
4
5
  require 'uri'
6
+ require 'timeout'
5
7
 
6
8
  module SplitIoClient
7
9
  module SSE
@@ -36,12 +38,12 @@ module SplitIoClient
36
38
 
37
39
  def close(status = nil)
38
40
  unless connected?
39
- @config.logger.error('SSEClient already disconected.') if @config.debug_enabled
41
+ log_if_debug('SSEClient already disconected.', 3)
40
42
  return
41
43
  end
42
44
 
43
45
  @connected.make_false
44
- @socket&.close
46
+ @socket.close
45
47
  push_status(status)
46
48
  rescue StandardError => e
47
49
  @config.logger.error("SSEClient close Error: #{e.inspect}")
@@ -74,30 +76,40 @@ module SplitIoClient
74
76
 
75
77
  def connect_thread(latch)
76
78
  @config.threads[:connect_stream] = Thread.new do
77
- @config.logger.info('Starting connect_stream thread ...') if @config.debug_enabled
79
+ log_if_debug('Starting connect_stream thread ...', 2)
78
80
  new_status = connect_stream(latch)
79
81
  push_status(new_status)
80
- @config.logger.info('connect_stream thread finished.') if @config.debug_enabled
82
+ log_if_debug('connect_stream thread finished.', 2)
81
83
  end
82
84
  end
83
85
 
84
86
  def connect_stream(latch)
85
87
  return Constants::PUSH_NONRETRYABLE_ERROR unless socket_write(latch)
86
-
87
88
  while connected? || @first_event.value
88
89
  begin
89
- partial_data = @socket.readpartial(10_000, timeout: @read_timeout)
90
-
90
+ partial_data = ""
91
+ Timeout::timeout @read_timeout do
92
+ partial_data = @socket.readpartial(10_000)
93
+ end
91
94
  read_first_event(partial_data, latch)
92
95
 
93
96
  raise 'eof exception' if partial_data == :eof
97
+ rescue Timeout::Error => e
98
+ log_if_debug("SSE read operation timed out!: #{e.inspect}", 3)
99
+ return Constants::PUSH_RETRYABLE_ERROR
100
+ rescue EOFError
101
+ raise 'eof exception'
102
+ rescue Errno::EAGAIN => e
103
+ log_if_debug("SSE client transient error: #{e.inspect}", 1)
104
+ IO.select([tcp_socket])
105
+ retry
94
106
  rescue Errno::EBADF, IOError => e
95
- @config.logger.error(e.inspect) if @config.debug_enabled
107
+ log_if_debug(e.inspect, 3)
96
108
  return nil
97
109
  rescue StandardError => e
98
110
  return nil if ENV['SPLITCLIENT_ENV'] == 'test'
99
111
 
100
- @config.logger.error("Error reading partial data: #{e.inspect}") if @config.debug_enabled
112
+ log_if_debug("Error reading partial data: #{e.inspect}", 3)
101
113
  return Constants::PUSH_RETRYABLE_ERROR
102
114
  end
103
115
 
@@ -109,10 +121,10 @@ module SplitIoClient
109
121
  def socket_write(latch)
110
122
  @first_event.make_true
111
123
  @socket = socket_connect
112
- @socket.write(build_request(@uri))
124
+ @socket.puts(build_request(@uri))
113
125
  true
114
126
  rescue StandardError => e
115
- @config.logger.error("Error during connecting to #{@uri.host}. Error: #{e.inspect}")
127
+ log_if_debug("Error during connecting to #{@uri.host}. Error: #{e.inspect}", 3)
116
128
  latch.count_down
117
129
  false
118
130
  end
@@ -138,15 +150,28 @@ module SplitIoClient
138
150
  end
139
151
 
140
152
  def socket_connect
141
- return Socketry::SSL::Socket.connect(@uri.host, @uri.port) if @uri.scheme.casecmp('https').zero?
153
+ tcp_socket = TCPSocket.new(@uri.host, @uri.port)
154
+ if @uri.scheme.casecmp('https').zero?
155
+ begin
156
+ ssl_context = OpenSSL::SSL::SSLContext.new
157
+ ssl_socket = OpenSSL::SSL::SSLSocket.new(tcp_socket, ssl_context)
158
+ ssl_socket.hostname = @uri.host
159
+ ssl_socket.connect
160
+ return ssl_socket.connect
161
+ rescue Exception => e
162
+ @config.logger.error("socket connect error: #{e.inspect}")
163
+ puts e.inspect
164
+ return nil
165
+ end
166
+ end
142
167
 
143
- Socketry::TCP::Socket.connect(@uri.host, @uri.port)
168
+ tcp_socket
144
169
  end
145
170
 
146
171
  def process_data(partial_data)
147
172
  return if partial_data.nil? || partial_data == KEEP_ALIVE_RESPONSE
148
173
 
149
- @config.logger.debug("Event partial data: #{partial_data}") if @config.debug_enabled
174
+ log_if_debug("Event partial data: #{partial_data}", 1)
150
175
  events = @event_parser.parse(partial_data)
151
176
  events.each { |event| process_event(event) }
152
177
  rescue StandardError => e
@@ -162,7 +187,7 @@ module SplitIoClient
162
187
  req << "SplitSDKMachineName: #{@config.machine_name}\r\n"
163
188
  req << "SplitSDKClientKey: #{@api_key.split(//).last(4).join}\r\n" unless @api_key.nil?
164
189
  req << "Cache-Control: no-cache\r\n\r\n"
165
- @config.logger.debug("Request info: #{req}") if @config.debug_enabled
190
+ log_if_debug("Request info: #{req}", 1)
166
191
  req
167
192
  end
168
193
 
@@ -200,6 +225,19 @@ module SplitIoClient
200
225
  @config.logger.debug("Pushing new sse status: #{status}")
201
226
  @status_queue.push(status)
202
227
  end
228
+
229
+ def log_if_debug(text, level)
230
+ if @config.debug_enabled
231
+ case level
232
+ when 1
233
+ @config.logger.debug(text)
234
+ when 2
235
+ @config.logger.info(text)
236
+ else
237
+ @config.logger.error(text)
238
+ end
239
+ end
240
+ end
203
241
  end
204
242
  end
205
243
  end
@@ -1,3 +1,3 @@
1
1
  module SplitIoClient
2
- VERSION = '8.9.0'
2
+ VERSION = '8.10.0-rc1'
3
3
  end
@@ -59,6 +59,5 @@ Gem::Specification.new do |spec|
59
59
  spec.add_runtime_dependency 'lru_redux', '~> 1.1'
60
60
  spec.add_runtime_dependency 'net-http-persistent', '>= 2.9', '< 5.0'
61
61
  spec.add_runtime_dependency 'redis', '>= 4.0.0', '< 6.0'
62
- spec.add_runtime_dependency 'socketry', '>= 0.4', '< 1.0'
63
62
  spec.add_runtime_dependency 'thread_safe', '~> 0.3'
64
63
  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: 8.9.0
4
+ version: 8.10.0.pre.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Split Software
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-10-08 00:00:00.000000000 Z
11
+ date: 2025-10-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: allocation_stats
@@ -362,26 +362,6 @@ dependencies:
362
362
  - - "<"
363
363
  - !ruby/object:Gem::Version
364
364
  version: '6.0'
365
- - !ruby/object:Gem::Dependency
366
- name: socketry
367
- requirement: !ruby/object:Gem::Requirement
368
- requirements:
369
- - - ">="
370
- - !ruby/object:Gem::Version
371
- version: '0.4'
372
- - - "<"
373
- - !ruby/object:Gem::Version
374
- version: '1.0'
375
- type: :runtime
376
- prerelease: false
377
- version_requirements: !ruby/object:Gem::Requirement
378
- requirements:
379
- - - ">="
380
- - !ruby/object:Gem::Version
381
- version: '0.4'
382
- - - "<"
383
- - !ruby/object:Gem::Version
384
- version: '1.0'
385
365
  - !ruby/object:Gem::Dependency
386
366
  name: thread_safe
387
367
  requirement: !ruby/object:Gem::Requirement
@@ -595,9 +575,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
595
575
  version: 2.5.0
596
576
  required_rubygems_version: !ruby/object:Gem::Requirement
597
577
  requirements:
598
- - - ">="
578
+ - - ">"
599
579
  - !ruby/object:Gem::Version
600
- version: '0'
580
+ version: 1.3.1
601
581
  requirements: []
602
582
  rubyforge_project:
603
583
  rubygems_version: 2.7.6.2