ld-eventsource 2.5.1 → 2.6.0
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/ld-eventsource/client.rb +31 -13
- data/lib/ld-eventsource/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1d455374db2a30af5cf5c6c94d94566eb8100e5598d013c519f098721cfba0f0
|
|
4
|
+
data.tar.gz: 7276a718d9faa59da461f3d958f802b26c377cb51fea06eec0334c42e2721562
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2b5eefef27e96b7179a5a92f71d5edeb141397a11d3c00867f4280c3e8db629714cd7cd29a1fa2365fcf5de3c5fa6240ca1890625efc95908b838d7471ff3223
|
|
7
|
+
data.tar.gz: 932d97eb452aec82bc79e5b3a08ed43192540968e6f07c2b301437cc453e3a3baf1f662d37c24cdde9763060d8e7ec97f826378e22f1370a66250c6819bb96af
|
|
@@ -52,6 +52,15 @@ module SSE
|
|
|
52
52
|
# The default HTTP method for requests.
|
|
53
53
|
DEFAULT_HTTP_METHOD = "GET"
|
|
54
54
|
|
|
55
|
+
# TODO(breaking): Remove this filtering once we have updated to the next major breaking version.
|
|
56
|
+
# HTTP v6 requires keyword arguments instead of an options hash, so we filter to only known valid
|
|
57
|
+
# arguments to avoid passing unsupported options.
|
|
58
|
+
VALID_HTTP_CLIENT_OPTIONS = %i[
|
|
59
|
+
base_uri body encoding features follow form headers json keep_alive_timeout
|
|
60
|
+
nodelay params persistent proxy response retriable socket_class ssl_context
|
|
61
|
+
ssl ssl_socket_class timeout_class timeout_options
|
|
62
|
+
].freeze
|
|
63
|
+
|
|
55
64
|
#
|
|
56
65
|
# Creates a new SSE client.
|
|
57
66
|
#
|
|
@@ -118,15 +127,15 @@ module SSE
|
|
|
118
127
|
@retry_enabled = retry_enabled
|
|
119
128
|
|
|
120
129
|
@headers = headers.clone
|
|
121
|
-
@connect_timeout = connect_timeout
|
|
122
|
-
@read_timeout = read_timeout
|
|
130
|
+
@connect_timeout = connect_timeout&.to_f
|
|
131
|
+
@read_timeout = read_timeout&.to_f
|
|
123
132
|
@method = method.to_s.upcase
|
|
124
133
|
@payload = payload
|
|
125
134
|
@logger = logger || default_logger
|
|
126
135
|
|
|
127
136
|
base_http_client_options = {}
|
|
128
137
|
if socket_factory
|
|
129
|
-
base_http_client_options[
|
|
138
|
+
base_http_client_options[:socket_class] = socket_factory
|
|
130
139
|
end
|
|
131
140
|
|
|
132
141
|
if proxy
|
|
@@ -139,22 +148,29 @@ module SSE
|
|
|
139
148
|
end
|
|
140
149
|
|
|
141
150
|
if @proxy
|
|
142
|
-
base_http_client_options[
|
|
151
|
+
base_http_client_options[:proxy] = {
|
|
143
152
|
:proxy_address => @proxy.host,
|
|
144
153
|
:proxy_port => @proxy.port,
|
|
145
154
|
}
|
|
146
|
-
base_http_client_options[
|
|
147
|
-
base_http_client_options[
|
|
155
|
+
base_http_client_options[:proxy][:proxy_username] = @proxy.user unless @proxy.user.nil?
|
|
156
|
+
base_http_client_options[:proxy][:proxy_password] = @proxy.password unless @proxy.password.nil?
|
|
148
157
|
end
|
|
149
158
|
|
|
150
159
|
options = http_client_options.is_a?(Hash) ? base_http_client_options.merge(http_client_options) : base_http_client_options
|
|
160
|
+
options = options.transform_keys(&:to_sym)
|
|
161
|
+
options = options.select do |key, _|
|
|
162
|
+
included = VALID_HTTP_CLIENT_OPTIONS.include?(key)
|
|
163
|
+
@logger.warn { "Ignoring unsupported HTTP client option: #{key}" } unless included
|
|
164
|
+
included
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
timeout_options = {}
|
|
168
|
+
timeout_options[:connect] = @connect_timeout if @connect_timeout
|
|
169
|
+
timeout_options[:read] = @read_timeout if @read_timeout
|
|
151
170
|
|
|
152
|
-
@http_client = HTTP::Client.new(options)
|
|
171
|
+
@http_client = HTTP::Client.new(**options)
|
|
153
172
|
.follow
|
|
154
|
-
|
|
155
|
-
read: read_timeout,
|
|
156
|
-
connect: connect_timeout,
|
|
157
|
-
})
|
|
173
|
+
@http_client = @http_client.timeout(timeout_options) unless timeout_options.empty?
|
|
158
174
|
@cxn = nil
|
|
159
175
|
@lock = Mutex.new
|
|
160
176
|
|
|
@@ -342,7 +358,7 @@ module SSE
|
|
|
342
358
|
begin
|
|
343
359
|
uri = build_uri_with_query_params
|
|
344
360
|
@logger.info { "Connecting to event stream at #{uri}" }
|
|
345
|
-
cxn = @http_client.request(@method, uri, build_opts)
|
|
361
|
+
cxn = @http_client.request(@method, uri, **build_opts)
|
|
346
362
|
headers = cxn.headers
|
|
347
363
|
if cxn.status.code == 200
|
|
348
364
|
content_type = cxn.content_type.mime_type
|
|
@@ -390,8 +406,10 @@ module SSE
|
|
|
390
406
|
rescue HTTP::TimeoutError
|
|
391
407
|
# For historical reasons, we rethrow this as our own type
|
|
392
408
|
raise Errors::ReadTimeoutError.new(@read_timeout)
|
|
409
|
+
rescue EOFError
|
|
410
|
+
break
|
|
393
411
|
end
|
|
394
|
-
break if data.nil?
|
|
412
|
+
break if data.nil? # keep for v5 compat
|
|
395
413
|
gen.yield data
|
|
396
414
|
end
|
|
397
415
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ld-eventsource
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.6.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- LaunchDarkly
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-03-
|
|
11
|
+
date: 2026-03-26 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: logger
|
|
@@ -117,7 +117,7 @@ dependencies:
|
|
|
117
117
|
version: 4.4.1
|
|
118
118
|
- - "<"
|
|
119
119
|
- !ruby/object:Gem::Version
|
|
120
|
-
version:
|
|
120
|
+
version: 7.0.0
|
|
121
121
|
type: :runtime
|
|
122
122
|
prerelease: false
|
|
123
123
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -127,7 +127,7 @@ dependencies:
|
|
|
127
127
|
version: 4.4.1
|
|
128
128
|
- - "<"
|
|
129
129
|
- !ruby/object:Gem::Version
|
|
130
|
-
version:
|
|
130
|
+
version: 7.0.0
|
|
131
131
|
description: LaunchDarkly SSE client for Ruby
|
|
132
132
|
email:
|
|
133
133
|
- team@launchdarkly.com
|