splitclient-rb 8.9.0 → 8.10.0.pre.rc2

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: 2a1f154dad854028971d56165b4d9c91f874ab4110083e7eb2560746d9f39868
4
+ data.tar.gz: e103dd790d41006bb8e39484b609b112a6811d0381dc10a763e0c600392d9fad
5
5
  SHA512:
6
- metadata.gz: b32b6fb272ff79f489bbb41adeb8ebd1c763dbe14aeffdc63c90b9c60ac7973ff212c28ffdecdaf5e5fd6215c5a92d4217d57e55d41b1af16107f1aa1141d092
7
- data.tar.gz: f8f5d13d8ab366ee267fa48e2c0b7b342c5b8a36e69ad961e10c708eb188d00a870b23a3c027b60fabd0e898664601128b1064b1ca712cd99f03e5c42841afb8
6
+ metadata.gz: a3ac4d6c11610bfb7b9146ff6cffc64352edfbb26bca397cca15e2654ce77162627c563707e45494b20e5933f21d489ee62d9d4703c35d363c7d584f1265e141
7
+ data.tar.gz: e77d244b4c912c2d912ffa09fbcc3bbd1e42fe3598defd5051f79d2d002f7fa40232fc7fd2426af28daa1e86ca4a089fd648e3581cd3eb3768793b948f85be85
@@ -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,38 @@ 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
+
160
+ begin
161
+ ssl_socket.connect_nonblock
162
+ rescue IO::WaitReadable
163
+ IO.select([ssl_socket])
164
+ retry
165
+ rescue IO::WaitWritable
166
+ IO.select(nil, [ssl_socket])
167
+ retry
168
+ end
169
+
170
+ return ssl_socket
171
+ # return ssl_socket.connect
172
+ rescue Exception => e
173
+ @config.logger.error("socket connect error: #{e.inspect}")
174
+ return nil
175
+ end
176
+ end
142
177
 
143
- Socketry::TCP::Socket.connect(@uri.host, @uri.port)
178
+ tcp_socket
144
179
  end
145
180
 
146
181
  def process_data(partial_data)
147
182
  return if partial_data.nil? || partial_data == KEEP_ALIVE_RESPONSE
148
183
 
149
- @config.logger.debug("Event partial data: #{partial_data}") if @config.debug_enabled
184
+ log_if_debug("Event partial data: #{partial_data}", 1)
150
185
  events = @event_parser.parse(partial_data)
151
186
  events.each { |event| process_event(event) }
152
187
  rescue StandardError => e
@@ -162,7 +197,7 @@ module SplitIoClient
162
197
  req << "SplitSDKMachineName: #{@config.machine_name}\r\n"
163
198
  req << "SplitSDKClientKey: #{@api_key.split(//).last(4).join}\r\n" unless @api_key.nil?
164
199
  req << "Cache-Control: no-cache\r\n\r\n"
165
- @config.logger.debug("Request info: #{req}") if @config.debug_enabled
200
+ log_if_debug("Request info: #{req}", 1)
166
201
  req
167
202
  end
168
203
 
@@ -200,6 +235,19 @@ module SplitIoClient
200
235
  @config.logger.debug("Pushing new sse status: #{status}")
201
236
  @status_queue.push(status)
202
237
  end
238
+
239
+ def log_if_debug(text, level)
240
+ if @config.debug_enabled
241
+ case level
242
+ when 1
243
+ @config.logger.debug(text)
244
+ when 2
245
+ @config.logger.info(text)
246
+ else
247
+ @config.logger.error(text)
248
+ end
249
+ end
250
+ end
203
251
  end
204
252
  end
205
253
  end
@@ -1,3 +1,3 @@
1
1
  module SplitIoClient
2
- VERSION = '8.9.0'
2
+ VERSION = '8.10.0-rc2'
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,13 @@
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.rc2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Split Software
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2025-10-08 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: allocation_stats
@@ -362,26 +361,6 @@ dependencies:
362
361
  - - "<"
363
362
  - !ruby/object:Gem::Version
364
363
  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
364
  - !ruby/object:Gem::Dependency
386
365
  name: thread_safe
387
366
  requirement: !ruby/object:Gem::Requirement
@@ -407,7 +386,6 @@ files:
407
386
  - ".github/CODEOWNERS"
408
387
  - ".github/pull_request_template.md"
409
388
  - ".github/workflows/ci.yml"
410
- - ".github/workflows/gem-push.yml"
411
389
  - ".github/workflows/update-license-year.yml"
412
390
  - ".gitignore"
413
391
  - ".rubocop.yml"
@@ -584,7 +562,6 @@ homepage: https://github.com/splitio/ruby-client
584
562
  licenses:
585
563
  - Apache-2.0
586
564
  metadata: {}
587
- post_install_message:
588
565
  rdoc_options: []
589
566
  require_paths:
590
567
  - lib
@@ -599,9 +576,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
599
576
  - !ruby/object:Gem::Version
600
577
  version: '0'
601
578
  requirements: []
602
- rubyforge_project:
603
- rubygems_version: 2.7.6.2
604
- signing_key:
579
+ rubygems_version: 3.7.1
605
580
  specification_version: 4
606
581
  summary: Ruby client for split SDK.
607
582
  test_files: []
@@ -1,40 +0,0 @@
1
- name: Ruby Gem
2
-
3
- on:
4
- push:
5
- branches: [ "release" ]
6
- pull_request:
7
- branches: [ "release" ]
8
-
9
- jobs:
10
- build:
11
- name: Build + Publish
12
- runs-on: ubuntu-latest
13
- permissions:
14
- contents: read
15
- packages: write
16
-
17
- steps:
18
- - uses: actions/checkout@v4
19
- - name: Set up Ruby 2.5.8
20
- # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
21
- # change this to (see https://github.com/ruby/setup-ruby#versioning):
22
- # uses: ruby/setup-ruby@v1
23
- uses: ruby/setup-ruby@v1
24
- with:
25
- ruby-version: 2.5.8
26
-
27
- - name: Publish to RubyGems
28
- run: |
29
- mkdir -p $HOME/.gem
30
- touch $HOME/.gem/credentials
31
- chmod 0600 $HOME/.gem/credentials
32
- printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
33
- gem build *.gemspec
34
- # gem push *.gem
35
- - name: upload gem file
36
- uses: actions/upload-artifact@v4
37
- with:
38
- name: gemspec
39
- path: ./*.gem
40
-