ld-eventsource 2.2.1 → 2.2.3
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/README.md +2 -1
- data/lib/ld-eventsource/client.rb +11 -13
- data/lib/ld-eventsource/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f4aa95953d325a67b03f0e740b9d1f898e7de4f7738e0449a6e3aaf2f7abe187
|
4
|
+
data.tar.gz: 0ae820e9665bd4c78bc801c09df14f6f6795057a7dc0048b698a4dd4b4d7106d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ceed9644f1d46f06b9def2675961215051aaf4059c94f2dd54142c6a37007becd987b459dd0eb9d640d29da08bba3aed9d567593b8594477202eef1b7042386f
|
7
|
+
data.tar.gz: e782c7a6baf52eba573aa2194c1f535b651bc2498dab036881a4b4226fcfe3f6830333d0a80dddfb32a6aeb5b4b85adf9fbc369c9638ec24dbcc78679804c7ea
|
data/README.md
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
LaunchDarkly SSE Client for Ruby
|
2
2
|
================================
|
3
3
|
|
4
|
-
[](http://badge.fury.io/rb/ld-eventsource)
|
4
|
+
[](http://badge.fury.io/rb/ld-eventsource)
|
5
|
+
[](https://github.com/launchdarkly/ruby-eventsource/actions/workflows/ci.yml)
|
5
6
|
|
6
7
|
A client for the [Server-Sent Events](https://www.w3.org/TR/eventsource/) protocol. This implementation runs on a worker thread, and uses the [`http`](https://rubygems.org/gems/http) gem to manage a persistent connection. Its primary purpose is to support the [LaunchDarkly SDK for Ruby](https://github.com/launchdarkly/ruby-client), but it can be used independently.
|
7
8
|
|
@@ -85,7 +85,7 @@ module SSE
|
|
85
85
|
# if you want to use something other than the default `TCPSocket`; it must implement
|
86
86
|
# `open(uri, timeout)` to return a connected `Socket`
|
87
87
|
# @yieldparam [Client] client the new client instance, before opening the connection
|
88
|
-
#
|
88
|
+
#
|
89
89
|
def initialize(uri,
|
90
90
|
headers: {},
|
91
91
|
connect_timeout: DEFAULT_CONNECT_TIMEOUT,
|
@@ -107,7 +107,7 @@ module SSE
|
|
107
107
|
if socket_factory
|
108
108
|
http_client_options["socket_class"] = socket_factory
|
109
109
|
end
|
110
|
-
|
110
|
+
|
111
111
|
if proxy
|
112
112
|
@proxy = proxy
|
113
113
|
else
|
@@ -141,9 +141,7 @@ module SSE
|
|
141
141
|
|
142
142
|
yield self if block_given?
|
143
143
|
|
144
|
-
Thread.new
|
145
|
-
run_stream
|
146
|
-
end
|
144
|
+
Thread.new { run_stream }.name = 'LD/SSEClient'
|
147
145
|
end
|
148
146
|
|
149
147
|
#
|
@@ -202,12 +200,12 @@ module SSE
|
|
202
200
|
end
|
203
201
|
|
204
202
|
private
|
205
|
-
|
203
|
+
|
206
204
|
def reset_http
|
207
205
|
@http_client.close if !@http_client.nil?
|
208
206
|
close_connection
|
209
207
|
end
|
210
|
-
|
208
|
+
|
211
209
|
def close_connection
|
212
210
|
@lock.synchronize do
|
213
211
|
@cxn.connection.close if !@cxn.nil?
|
@@ -258,7 +256,7 @@ module SSE
|
|
258
256
|
interval = @first_attempt ? 0 : @backoff.next_interval
|
259
257
|
@first_attempt = false
|
260
258
|
if interval > 0
|
261
|
-
@logger.info { "Will retry connection after #{'%.3f' % interval} seconds" }
|
259
|
+
@logger.info { "Will retry connection after #{'%.3f' % interval} seconds" }
|
262
260
|
sleep(interval)
|
263
261
|
end
|
264
262
|
cxn = nil
|
@@ -268,14 +266,14 @@ module SSE
|
|
268
266
|
headers: build_headers
|
269
267
|
})
|
270
268
|
if cxn.status.code == 200
|
271
|
-
content_type = cxn.
|
269
|
+
content_type = cxn.content_type.mime_type
|
272
270
|
if content_type && content_type.start_with?("text/event-stream")
|
273
271
|
return cxn # we're good to proceed
|
274
272
|
else
|
275
273
|
reset_http
|
276
|
-
err = Errors::HTTPContentTypeError.new(
|
274
|
+
err = Errors::HTTPContentTypeError.new(content_type)
|
277
275
|
@on[:error].call(err)
|
278
|
-
@logger.warn { "Event source returned unexpected content type '#{
|
276
|
+
@logger.warn { "Event source returned unexpected content type '#{content_type}'" }
|
279
277
|
end
|
280
278
|
else
|
281
279
|
body = cxn.to_s # grab the whole response body in case it has error details
|
@@ -309,7 +307,7 @@ module SSE
|
|
309
307
|
# readpartial gives us a string, which may not be a valid UTF-8 string because a
|
310
308
|
# multi-byte character might not yet have been fully read, but BufferedLineReader
|
311
309
|
# will handle that.
|
312
|
-
rescue HTTP::TimeoutError
|
310
|
+
rescue HTTP::TimeoutError
|
313
311
|
# For historical reasons, we rethrow this as our own type
|
314
312
|
raise Errors::ReadTimeoutError.new(@read_timeout)
|
315
313
|
end
|
@@ -344,7 +342,7 @@ module SSE
|
|
344
342
|
@logger.warn { "#{message}: #{e.inspect}"}
|
345
343
|
@logger.debug { "Exception trace: #{e.backtrace}" }
|
346
344
|
begin
|
347
|
-
@on[:error].call(e)
|
345
|
+
@on[:error].call(e)
|
348
346
|
rescue StandardError => ee
|
349
347
|
@logger.warn { "Error handler threw an exception: #{ee.inspect}"}
|
350
348
|
@logger.debug { "Exception trace: #{ee.backtrace}" }
|
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.2.
|
4
|
+
version: 2.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- LaunchDarkly
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-03-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -121,7 +121,7 @@ homepage: https://github.com/launchdarkly/ruby-eventsource
|
|
121
121
|
licenses:
|
122
122
|
- Apache-2.0
|
123
123
|
metadata: {}
|
124
|
-
post_install_message:
|
124
|
+
post_install_message:
|
125
125
|
rdoc_options: []
|
126
126
|
require_paths:
|
127
127
|
- lib
|
@@ -136,8 +136,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
136
136
|
- !ruby/object:Gem::Version
|
137
137
|
version: '0'
|
138
138
|
requirements: []
|
139
|
-
rubygems_version: 3.
|
140
|
-
signing_key:
|
139
|
+
rubygems_version: 3.2.33
|
140
|
+
signing_key:
|
141
141
|
specification_version: 4
|
142
142
|
summary: LaunchDarkly SSE client
|
143
143
|
test_files: []
|