ld-eventsource 2.1.0 → 2.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ld-eventsource/client.rb +34 -44
- data/lib/ld-eventsource/impl/buffered_line_reader.rb +73 -0
- data/lib/ld-eventsource/impl/event_parser.rb +6 -4
- data/lib/ld-eventsource/version.rb +1 -1
- metadata +5 -29
- data/.circleci/config.yml +0 -39
- data/.gitignore +0 -17
- data/.ldrelease/circleci/linux/execute.sh +0 -18
- data/.ldrelease/circleci/mac/execute.sh +0 -18
- data/.ldrelease/circleci/template/build.sh +0 -19
- data/.ldrelease/circleci/template/gems-setup.sh +0 -16
- data/.ldrelease/circleci/template/prepare.sh +0 -17
- data/.ldrelease/circleci/template/publish.sh +0 -19
- data/.ldrelease/circleci/template/test.sh +0 -10
- data/.ldrelease/circleci/template/update-version.sh +0 -8
- data/.ldrelease/circleci/windows/execute.ps1 +0 -19
- data/.ldrelease/config.yml +0 -22
- data/CHANGELOG.md +0 -35
- data/Gemfile +0 -3
- data/ld-eventsource.gemspec +0 -30
- data/scripts/gendocs.sh +0 -12
- data/scripts/release.sh +0 -30
- data/spec/backoff_spec.rb +0 -52
- data/spec/client_spec.rb +0 -444
- data/spec/event_parser_spec.rb +0 -100
- data/spec/http_stub.rb +0 -83
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 14623ca76eeb863804646a598dec0a4f368bdd4fbf8875b7d5bb1be62c1845bd
|
4
|
+
data.tar.gz: 9c9d521d4e10f01f93f04431acfbbe2821434e99dd2738c09726827a84a96ed2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4fccea73f41283286656e7a8ad8d10c72e0175b68a34499008d38d897d9a8828000d3f9cdb582dca682e182d1d0045240d0522fd9e28e72401410aad668a603d
|
7
|
+
data.tar.gz: c0756a730b152c06e7a1497703d1acdc0216a9ad8938798914fda239011d34d4c5bf521d51f3cf4f06829e6830befb550d9a47bf6d9fa19bda9ee3e2ba08972b
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require "ld-eventsource/impl/backoff"
|
2
|
+
require "ld-eventsource/impl/buffered_line_reader"
|
2
3
|
require "ld-eventsource/impl/event_parser"
|
3
4
|
require "ld-eventsource/events"
|
4
5
|
require "ld-eventsource/errors"
|
@@ -128,11 +129,12 @@ module SSE
|
|
128
129
|
read: read_timeout,
|
129
130
|
connect: connect_timeout
|
130
131
|
})
|
131
|
-
@
|
132
|
+
@cxn = nil
|
132
133
|
@lock = Mutex.new
|
133
134
|
|
134
135
|
@backoff = Impl::Backoff.new(reconnect_time || DEFAULT_RECONNECT_TIME, MAX_RECONNECT_TIME,
|
135
136
|
reconnect_reset_interval: reconnect_reset_interval)
|
137
|
+
@first_attempt = true
|
136
138
|
|
137
139
|
@on = { event: ->(_) {}, error: ->(_) {} }
|
138
140
|
@last_id = last_event_id
|
@@ -203,47 +205,14 @@ module SSE
|
|
203
205
|
|
204
206
|
def reset_http
|
205
207
|
@http_client.close if !@http_client.nil?
|
206
|
-
|
207
|
-
@buffer = ""
|
208
|
-
end
|
209
|
-
|
210
|
-
def read_lines
|
211
|
-
Enumerator.new do |gen|
|
212
|
-
loop do
|
213
|
-
line = read_line
|
214
|
-
break if line.nil?
|
215
|
-
gen.yield line
|
216
|
-
end
|
217
|
-
end
|
218
|
-
end
|
219
|
-
|
220
|
-
def read_line
|
221
|
-
loop do
|
222
|
-
@lock.synchronize do
|
223
|
-
i = @buffer.index(/[\r\n]/)
|
224
|
-
if !i.nil? && !(i == @buffer.length - 1 && @buffer[i] == "\r")
|
225
|
-
i += 1 if (@buffer[i] == "\r" && @buffer[i + 1] == "\n")
|
226
|
-
return @buffer.slice!(0, i + 1).force_encoding(Encoding::UTF_8)
|
227
|
-
end
|
228
|
-
end
|
229
|
-
return nil if !read_chunk_into_buffer
|
230
|
-
end
|
208
|
+
close_connection
|
231
209
|
end
|
232
210
|
|
233
|
-
def
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
data = @cxn.readpartial
|
238
|
-
rescue HTTP::TimeoutError
|
239
|
-
# We rethrow this as our own type so the caller doesn't have to know the httprb API
|
240
|
-
raise Errors::ReadTimeoutError.new(@read_timeout)
|
211
|
+
def close_connection
|
212
|
+
@lock.synchronize do
|
213
|
+
@cxn.connection.close if !@cxn.nil?
|
214
|
+
@cxn = nil
|
241
215
|
end
|
242
|
-
return false if data == nil
|
243
|
-
@buffer << data
|
244
|
-
# We are piping the content through the parser so that it can handle things like chunked
|
245
|
-
# encoding for us. The content ends up being appended to @buffer via our callback.
|
246
|
-
true
|
247
216
|
end
|
248
217
|
|
249
218
|
def default_logger
|
@@ -255,13 +224,16 @@ module SSE
|
|
255
224
|
|
256
225
|
def run_stream
|
257
226
|
while !@stopped.value
|
258
|
-
|
227
|
+
close_connection
|
259
228
|
begin
|
260
|
-
|
229
|
+
resp = connect
|
230
|
+
@lock.synchronize do
|
231
|
+
@cxn = resp
|
232
|
+
end
|
261
233
|
# There's a potential race if close was called in the middle of the previous line, i.e. after we
|
262
234
|
# connected but before @cxn was set. Checking the variable again is a bit clunky but avoids that.
|
263
235
|
return if @stopped.value
|
264
|
-
read_stream(
|
236
|
+
read_stream(resp) if !resp.nil?
|
265
237
|
rescue => e
|
266
238
|
# When we deliberately close the connection, it will usually trigger an exception. The exact type
|
267
239
|
# of exception depends on the specific Ruby runtime. But @stopped will always be set in this case.
|
@@ -283,7 +255,8 @@ module SSE
|
|
283
255
|
def connect
|
284
256
|
loop do
|
285
257
|
return if @stopped.value
|
286
|
-
interval = @backoff.next_interval
|
258
|
+
interval = @first_attempt ? 0 : @backoff.next_interval
|
259
|
+
@first_attempt = false
|
287
260
|
if interval > 0
|
288
261
|
@logger.info { "Will retry connection after #{'%.3f' % interval} seconds" }
|
289
262
|
sleep(interval)
|
@@ -326,7 +299,24 @@ module SSE
|
|
326
299
|
# it can automatically reset itself if enough time passes between failures.
|
327
300
|
@backoff.mark_success
|
328
301
|
|
329
|
-
|
302
|
+
chunks = Enumerator.new do |gen|
|
303
|
+
loop do
|
304
|
+
if @stopped.value
|
305
|
+
break
|
306
|
+
else
|
307
|
+
begin
|
308
|
+
data = cxn.readpartial
|
309
|
+
rescue HTTP::TimeoutError
|
310
|
+
# For historical reasons, we rethrow this as our own type
|
311
|
+
raise Errors::ReadTimeoutError.new(@read_timeout)
|
312
|
+
end
|
313
|
+
break if data.nil?
|
314
|
+
gen.yield data
|
315
|
+
end
|
316
|
+
end
|
317
|
+
end
|
318
|
+
event_parser = Impl::EventParser.new(Impl::BufferedLineReader.lines_from(chunks))
|
319
|
+
|
330
320
|
event_parser.items.each do |item|
|
331
321
|
return if @stopped.value
|
332
322
|
case item
|
@@ -0,0 +1,73 @@
|
|
1
|
+
|
2
|
+
module SSE
|
3
|
+
module Impl
|
4
|
+
class BufferedLineReader
|
5
|
+
#
|
6
|
+
# Reads a series of data chunks from an enumerator, and returns an enumerator that
|
7
|
+
# parses/aggregates these into text lines. The line terminator may be CR, LF, or
|
8
|
+
# CRLF for each line; terminators are not included in the returned lines. When the
|
9
|
+
# input data runs out, the output enumerator ends and does not include any partially
|
10
|
+
# completed line.
|
11
|
+
#
|
12
|
+
# @param [Enumerator] chunks an enumerator that will yield strings from a stream
|
13
|
+
# @return [Enumerator] an enumerator that will yield one line at a time
|
14
|
+
#
|
15
|
+
def self.lines_from(chunks)
|
16
|
+
buffer = ""
|
17
|
+
position = 0
|
18
|
+
line_start = 0
|
19
|
+
last_char_was_cr = false
|
20
|
+
|
21
|
+
Enumerator.new do |gen|
|
22
|
+
chunks.each do |chunk|
|
23
|
+
buffer << chunk
|
24
|
+
|
25
|
+
loop do
|
26
|
+
# Search for a line break in any part of the buffer that we haven't yet seen.
|
27
|
+
i = buffer.index(/[\r\n]/, position)
|
28
|
+
if i.nil?
|
29
|
+
# There isn't a line break yet, so we'll keep accumulating data in the buffer, using
|
30
|
+
# position to keep track of where we left off scanning. We can also discard any previously
|
31
|
+
# parsed lines from the buffer at this point.
|
32
|
+
if line_start > 0
|
33
|
+
buffer.slice!(0, line_start)
|
34
|
+
line_start = 0
|
35
|
+
end
|
36
|
+
position = buffer.length
|
37
|
+
break
|
38
|
+
end
|
39
|
+
|
40
|
+
ch = buffer[i]
|
41
|
+
if i == 0 && ch == "\n" && last_char_was_cr
|
42
|
+
# This is just the dangling LF of a CRLF pair
|
43
|
+
last_char_was_cr = false
|
44
|
+
i += 1
|
45
|
+
position = i
|
46
|
+
line_start = i
|
47
|
+
next
|
48
|
+
end
|
49
|
+
|
50
|
+
line = buffer[line_start, i - line_start]
|
51
|
+
last_char_was_cr = false
|
52
|
+
i += 1
|
53
|
+
if ch == "\r"
|
54
|
+
if i == buffer.length
|
55
|
+
last_char_was_cr = true # We'll break the line here, but be on watch for a dangling LF
|
56
|
+
elsif buffer[i] == "\n"
|
57
|
+
i += 1
|
58
|
+
end
|
59
|
+
end
|
60
|
+
if i == buffer.length
|
61
|
+
buffer = ""
|
62
|
+
i = 0
|
63
|
+
end
|
64
|
+
position = i
|
65
|
+
line_start = i
|
66
|
+
gen.yield line
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -20,7 +20,8 @@ module SSE
|
|
20
20
|
#
|
21
21
|
# Constructs an instance of EventParser.
|
22
22
|
#
|
23
|
-
# @param [Enumerator] lines an enumerator that will yield one line of text at a time
|
23
|
+
# @param [Enumerator] lines an enumerator that will yield one line of text at a time;
|
24
|
+
# the lines should not include line terminators
|
24
25
|
#
|
25
26
|
def initialize(lines)
|
26
27
|
@lines = lines
|
@@ -31,7 +32,6 @@ module SSE
|
|
31
32
|
def items
|
32
33
|
Enumerator.new do |gen|
|
33
34
|
@lines.each do |line|
|
34
|
-
line.chomp!
|
35
35
|
if line.empty?
|
36
36
|
event = maybe_create_event
|
37
37
|
reset_buffers
|
@@ -53,6 +53,7 @@ module SSE
|
|
53
53
|
@id = nil
|
54
54
|
@type = nil
|
55
55
|
@data = ""
|
56
|
+
@have_data = false
|
56
57
|
end
|
57
58
|
|
58
59
|
def process_field(name, value)
|
@@ -60,8 +61,9 @@ module SSE
|
|
60
61
|
when "event"
|
61
62
|
@type = value.to_sym
|
62
63
|
when "data"
|
63
|
-
@data << "\n" if
|
64
|
+
@data << "\n" if @have_data
|
64
65
|
@data << value
|
66
|
+
@have_data = true
|
65
67
|
when "id"
|
66
68
|
@id = value
|
67
69
|
when "retry"
|
@@ -73,7 +75,7 @@ module SSE
|
|
73
75
|
end
|
74
76
|
|
75
77
|
def maybe_create_event
|
76
|
-
return nil if
|
78
|
+
return nil if !@have_data
|
77
79
|
StreamEvent.new(@type || :message, @data, @id)
|
78
80
|
end
|
79
81
|
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.1.
|
4
|
+
version: 2.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- LaunchDarkly
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-10-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -107,36 +107,16 @@ executables: []
|
|
107
107
|
extensions: []
|
108
108
|
extra_rdoc_files: []
|
109
109
|
files:
|
110
|
-
- ".circleci/config.yml"
|
111
|
-
- ".gitignore"
|
112
|
-
- ".ldrelease/circleci/linux/execute.sh"
|
113
|
-
- ".ldrelease/circleci/mac/execute.sh"
|
114
|
-
- ".ldrelease/circleci/template/build.sh"
|
115
|
-
- ".ldrelease/circleci/template/gems-setup.sh"
|
116
|
-
- ".ldrelease/circleci/template/prepare.sh"
|
117
|
-
- ".ldrelease/circleci/template/publish.sh"
|
118
|
-
- ".ldrelease/circleci/template/test.sh"
|
119
|
-
- ".ldrelease/circleci/template/update-version.sh"
|
120
|
-
- ".ldrelease/circleci/windows/execute.ps1"
|
121
|
-
- ".ldrelease/config.yml"
|
122
|
-
- CHANGELOG.md
|
123
|
-
- Gemfile
|
124
110
|
- LICENSE
|
125
111
|
- README.md
|
126
|
-
- ld-eventsource.gemspec
|
127
112
|
- lib/ld-eventsource.rb
|
128
113
|
- lib/ld-eventsource/client.rb
|
129
114
|
- lib/ld-eventsource/errors.rb
|
130
115
|
- lib/ld-eventsource/events.rb
|
131
116
|
- lib/ld-eventsource/impl/backoff.rb
|
117
|
+
- lib/ld-eventsource/impl/buffered_line_reader.rb
|
132
118
|
- lib/ld-eventsource/impl/event_parser.rb
|
133
119
|
- lib/ld-eventsource/version.rb
|
134
|
-
- scripts/gendocs.sh
|
135
|
-
- scripts/release.sh
|
136
|
-
- spec/backoff_spec.rb
|
137
|
-
- spec/client_spec.rb
|
138
|
-
- spec/event_parser_spec.rb
|
139
|
-
- spec/http_stub.rb
|
140
120
|
homepage: https://github.com/launchdarkly/ruby-eventsource
|
141
121
|
licenses:
|
142
122
|
- Apache-2.0
|
@@ -156,12 +136,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
156
136
|
- !ruby/object:Gem::Version
|
157
137
|
version: '0'
|
158
138
|
requirements: []
|
159
|
-
rubygems_version: 3.2.
|
139
|
+
rubygems_version: 3.2.29
|
160
140
|
signing_key:
|
161
141
|
specification_version: 4
|
162
142
|
summary: LaunchDarkly SSE client
|
163
|
-
test_files:
|
164
|
-
- spec/backoff_spec.rb
|
165
|
-
- spec/client_spec.rb
|
166
|
-
- spec/event_parser_spec.rb
|
167
|
-
- spec/http_stub.rb
|
143
|
+
test_files: []
|
data/.circleci/config.yml
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
# This CircleCI configuration was generated by Releaser for a specific release. It is not to be used
|
2
|
-
# for regular CI builds. Be aware that rerunning this build may cause it to repeat release actions
|
3
|
-
# such as publishing to a package manager. However, it will not perform any Git actions other than
|
4
|
-
# reading the repository.
|
5
|
-
version: 2.1
|
6
|
-
workflows:
|
7
|
-
test:
|
8
|
-
jobs:
|
9
|
-
- release_linux:
|
10
|
-
context: org-global
|
11
|
-
jobs:
|
12
|
-
release_linux:
|
13
|
-
docker:
|
14
|
-
- image: cimg/ruby:2.5
|
15
|
-
environment:
|
16
|
-
LD_RELEASE_CIRCLECI_TYPE: linux
|
17
|
-
LD_RELEASE_BRANCH: "master"
|
18
|
-
LD_RELEASE_CIRCLECI_BRANCH: ""
|
19
|
-
LD_RELEASE_DOCS_GITHUB_PAGES: ""
|
20
|
-
LD_RELEASE_DOCS_TITLE: ""
|
21
|
-
LD_RELEASE_PROJECT: "ruby-eventsource"
|
22
|
-
LD_RELEASE_PROJECT_TEMPLATE: "ruby"
|
23
|
-
LD_RELEASE_VERSION: "2.1.0"
|
24
|
-
steps:
|
25
|
-
- checkout
|
26
|
-
- run:
|
27
|
-
name: "Releaser: prepare"
|
28
|
-
command: .ldrelease/circleci/mac/execute.sh prepare .ldrelease/circleci/template/prepare.sh
|
29
|
-
- run:
|
30
|
-
name: "Releaser: build"
|
31
|
-
command: .ldrelease/circleci/mac/execute.sh build .ldrelease/circleci/template/build.sh
|
32
|
-
- run:
|
33
|
-
name: "Releaser: test"
|
34
|
-
command: .ldrelease/circleci/mac/execute.sh test .ldrelease/circleci/template/test.sh
|
35
|
-
- run:
|
36
|
-
name: "Releaser: publish"
|
37
|
-
command: .ldrelease/circleci/mac/execute.sh publish .ldrelease/circleci/template/publish.sh
|
38
|
-
- store_artifacts:
|
39
|
-
path: artifacts
|
data/.gitignore
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
#!/bin/bash
|
2
|
-
|
3
|
-
set -ue
|
4
|
-
|
5
|
-
# Performs a delegated release step in a CircleCI Linux container. This mechanism is described
|
6
|
-
# in scripts/circleci/README.md. All of the necessary environment variables should already be
|
7
|
-
# in the generated CircleCI configuration.
|
8
|
-
|
9
|
-
mkdir -p artifacts
|
10
|
-
|
11
|
-
export LD_RELEASE_TEMP_DIR=/tmp/project-releaser-temp
|
12
|
-
mkdir -p ${LD_RELEASE_TEMP_DIR}
|
13
|
-
|
14
|
-
STEP="$1"
|
15
|
-
SCRIPT="$2"
|
16
|
-
echo
|
17
|
-
echo "[${STEP}] executing ${SCRIPT}"
|
18
|
-
"./${SCRIPT}"
|
@@ -1,18 +0,0 @@
|
|
1
|
-
#!/bin/bash
|
2
|
-
|
3
|
-
set -ue
|
4
|
-
|
5
|
-
# Performs a delegated release step in a CircleCI Mac container. This mechanism is described
|
6
|
-
# in scripts/circleci/README.md. All of the necessary environment variables should already be
|
7
|
-
# in the generated CircleCI configuration.
|
8
|
-
|
9
|
-
mkdir -p artifacts
|
10
|
-
|
11
|
-
export LD_RELEASE_TEMP_DIR=/tmp/project-releaser-temp
|
12
|
-
mkdir -p ${LD_RELEASE_TEMP_DIR}
|
13
|
-
|
14
|
-
STEP="$1"
|
15
|
-
SCRIPT="$2"
|
16
|
-
echo
|
17
|
-
echo "[${STEP}] executing ${SCRIPT}"
|
18
|
-
"./${SCRIPT}"
|
@@ -1,19 +0,0 @@
|
|
1
|
-
#!/bin/bash
|
2
|
-
|
3
|
-
set -ue
|
4
|
-
|
5
|
-
# Standard build.sh for Ruby-based projects that publish a gem
|
6
|
-
|
7
|
-
echo "Using gem $(gem --version)"
|
8
|
-
|
9
|
-
#shellcheck source=/dev/null
|
10
|
-
source "$(dirname "$0")/gems-setup.sh"
|
11
|
-
|
12
|
-
echo; echo "Installing dependencies"
|
13
|
-
${BUNDLER_COMMAND} install
|
14
|
-
|
15
|
-
# Build Ruby Gem - this assumes there is a single .gemspec file in the main project directory
|
16
|
-
# Note that the gemspec must be able to get the project version either from $LD_RELEASE_VERSION,
|
17
|
-
# or from somewhere in the source code that the project-specific update-version.sh has updated.
|
18
|
-
echo "Running gem build"
|
19
|
-
gem build ./*.gemspec || { echo "gem build failed" >&2; exit 1; }
|
@@ -1,16 +0,0 @@
|
|
1
|
-
#!/bin/bash
|
2
|
-
|
3
|
-
# helper script to set GEM_HOME, PATH, and BUNDLER_COMMAND for Ruby - must be sourced, not executed
|
4
|
-
|
5
|
-
mkdir -p "${LD_RELEASE_TEMP_DIR}/gems"
|
6
|
-
export GEM_HOME="${LD_RELEASE_TEMP_DIR}/gems"
|
7
|
-
export PATH="${GEM_HOME}/bin:${PATH}"
|
8
|
-
|
9
|
-
# also, determine whether we'll need to run a specific version of Bundler
|
10
|
-
|
11
|
-
GEMSPEC_BUNDLER_VERSION=$(sed -n -e "s/.*['\"]bundler['\"], *['\"]\([^'\"]*\)['\"]/\1/p" ./*.gemspec | tr -d ' ')
|
12
|
-
if [ -n "${GEMSPEC_BUNDLER_VERSION}" ]; then
|
13
|
-
BUNDLER_COMMAND="bundler _${GEMSPEC_BUNDLER_VERSION}_"
|
14
|
-
else
|
15
|
-
BUNDLER_COMMAND="bundler"
|
16
|
-
fi
|
@@ -1,17 +0,0 @@
|
|
1
|
-
#!/bin/bash
|
2
|
-
|
3
|
-
set -ue
|
4
|
-
|
5
|
-
echo "Using gem $(gem --version)"
|
6
|
-
|
7
|
-
#shellcheck source=/dev/null
|
8
|
-
source "$(dirname "$0")/gems-setup.sh"
|
9
|
-
|
10
|
-
# If the gemspec specifies a certain version of bundler, we need to make sure we install that version.
|
11
|
-
echo "Installing bundler"
|
12
|
-
if [ -n "${GEMSPEC_BUNDLER_VERSION:-}" ]; then
|
13
|
-
GEMSPEC_OPTIONS="-v ${GEMSPEC_BUNDLER_VERSION}"
|
14
|
-
else
|
15
|
-
GEMSPEC_OPTIONS=""
|
16
|
-
fi
|
17
|
-
gem install bundler ${GEMSPEC_OPTIONS} || { echo "installing bundler failed" >&2; exit 1; }
|
@@ -1,19 +0,0 @@
|
|
1
|
-
#!/bin/bash
|
2
|
-
|
3
|
-
set -ue
|
4
|
-
|
5
|
-
# Standard publish.sh for Ruby-based projects - we can assume build.sh has already been run
|
6
|
-
|
7
|
-
#shellcheck source=/dev/null
|
8
|
-
source "$(dirname "$0")/gems-setup.sh"
|
9
|
-
|
10
|
-
# If we're running in CircleCI, the RubyGems credentials will be in an environment
|
11
|
-
# variable and should be copied to the variable the gem command expects
|
12
|
-
if [ -n "${LD_RELEASE_RUBYGEMS_API_KEY:-}" ]; then
|
13
|
-
export GEM_HOST_API_KEY="${LD_RELEASE_RUBYGEMS_API_KEY}"
|
14
|
-
fi
|
15
|
-
|
16
|
-
# Since all Releaser builds are clean builds, we can assume that the only .gem file here
|
17
|
-
# is the one we just built
|
18
|
-
echo "Running gem push"
|
19
|
-
gem push ./*.gem || { echo "gem push failed" >&2; exit 1; }
|
@@ -1,8 +0,0 @@
|
|
1
|
-
#!/bin/bash
|
2
|
-
|
3
|
-
set -ue
|
4
|
-
|
5
|
-
# Standard update-version.sh for Ruby-based projects - this will work only if the version string
|
6
|
-
# is in a source file under lib/ that has a line like his: VERSION = "2.0.0"
|
7
|
-
|
8
|
-
"$(dirname "$0")/../update-version-constant.sh" lib '*.rb'
|
@@ -1,19 +0,0 @@
|
|
1
|
-
param(
|
2
|
-
[string]$step,
|
3
|
-
[string]$script
|
4
|
-
)
|
5
|
-
|
6
|
-
# Performs a delegated release step in a CircleCI Windows container using PowerShell. This
|
7
|
-
# mechanism is described in scripts/circleci/README.md. All of the necessary environment
|
8
|
-
# variables should already be in the generated CircleCI configuration.
|
9
|
-
|
10
|
-
$ErrorActionPreference = "Stop"
|
11
|
-
|
12
|
-
New-Item -Path "./artifacts" -ItemType "directory" -Force | Out-Null
|
13
|
-
|
14
|
-
$env:LD_RELEASE_TEMP_DIR = "$env:TEMP\project-releaser-temp"
|
15
|
-
New-Item -Path $env:LD_RELEASE_TEMP_DIR -ItemType "directory" -Force | Out-Null
|
16
|
-
|
17
|
-
Write-Host
|
18
|
-
Write-Host "[$step] executing $script"
|
19
|
-
& "./$script"
|
data/.ldrelease/config.yml
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
repo:
|
2
|
-
public: ruby-eventsource
|
3
|
-
|
4
|
-
publications:
|
5
|
-
- url: https://rubygems.org/gems/ld-eventsource
|
6
|
-
description: RubyGems
|
7
|
-
- url: https://www.rubydoc.info/gems/ld-eventsource
|
8
|
-
description: documentation
|
9
|
-
|
10
|
-
releasableBranches:
|
11
|
-
- name: master
|
12
|
-
description: 2.x - based on the http gem
|
13
|
-
- name: 1.x
|
14
|
-
description: 1.x - based on the socketry gem
|
15
|
-
|
16
|
-
circleci:
|
17
|
-
linux:
|
18
|
-
image: cimg/ruby:2.5
|
19
|
-
context: org-global
|
20
|
-
|
21
|
-
template:
|
22
|
-
name: ruby
|
data/CHANGELOG.md
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
# Change log
|
2
|
-
|
3
|
-
All notable changes to the LaunchDarkly SSE Client for Ruby will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org).
|
4
|
-
|
5
|
-
## [2.0.1] - 2021-08-10
|
6
|
-
### Changed:
|
7
|
-
- The dependency version constraint for the `http` gem is now looser: it allows 5.x versions as well as 4.x. The breaking changes in `http` v5.0.0 do not affect `ld-eventsource`.
|
8
|
-
- The project's build now uses v2.2.10 of `bundler` due to known vulnerabilities in other versions.
|
9
|
-
- `Gemfile.lock` has been removed from source control. As this is a library project, the lockfile never affected application code that used this gem, but only affected the gem's own CI build. It is preferable for the CI build to refer only to the gemspec so that it resolves dependencies the same way an application using this gem would, rather than using pinned dependencies that an application would not use.
|
10
|
-
|
11
|
-
## [2.0.0] - 2021-01-26
|
12
|
-
### Added:
|
13
|
-
- Added a `socket_factory` configuration option which can be used for socket creation by the HTTP client if provided. The value of `socket_factory` must be an object providing an `open(uri, timeout)` method and returning a connected socket.
|
14
|
-
|
15
|
-
### Changed:
|
16
|
-
- Switched to the `http` gem instead of `socketry` and a custom HTTP client.
|
17
|
-
- Dropped support for Ruby < version 2.5
|
18
|
-
- Dropped support for JRuby < version 9.2
|
19
|
-
|
20
|
-
## [1.0.3] - 2020-03-17
|
21
|
-
### Fixed:
|
22
|
-
- The backoff delay logic for reconnecting after a stream failure was broken so that if a failure occurred after a stream had been active for at least `reconnect_reset_interval` (default 60 seconds), retries would use _no_ delay, potentially causing a flood of requests and a spike in CPU usage.
|
23
|
-
|
24
|
-
## [1.0.2] - 2020-03-10
|
25
|
-
### Removed:
|
26
|
-
- Removed an unused dependency on `rake`. There are no other changes in this release.
|
27
|
-
|
28
|
-
|
29
|
-
## [1.0.1] - 2019-07-10
|
30
|
-
### Fixed:
|
31
|
-
- Calling `close` on the client could cause a misleading warning message in the log, such as `Unexpected error from event source: #<IOError: stream closed in another thread>`.
|
32
|
-
|
33
|
-
## [1.0.0] - 2019-01-03
|
34
|
-
|
35
|
-
Initial release.
|
data/Gemfile
DELETED
data/ld-eventsource.gemspec
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
|
3
|
-
lib = File.expand_path("../lib", __FILE__)
|
4
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
-
require "ld-eventsource/version"
|
6
|
-
|
7
|
-
# rubocop:disable Metrics/BlockLength
|
8
|
-
Gem::Specification.new do |spec|
|
9
|
-
spec.name = "ld-eventsource"
|
10
|
-
spec.version = SSE::VERSION
|
11
|
-
spec.authors = ["LaunchDarkly"]
|
12
|
-
spec.email = ["team@launchdarkly.com"]
|
13
|
-
spec.summary = "LaunchDarkly SSE client"
|
14
|
-
spec.description = "LaunchDarkly SSE client for Ruby"
|
15
|
-
spec.homepage = "https://github.com/launchdarkly/ruby-eventsource"
|
16
|
-
spec.license = "Apache-2.0"
|
17
|
-
|
18
|
-
spec.files = `git ls-files -z`.split("\x0")
|
19
|
-
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
20
|
-
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
21
|
-
spec.require_paths = ["lib"]
|
22
|
-
|
23
|
-
spec.add_development_dependency "bundler", "2.2.10"
|
24
|
-
spec.add_development_dependency "rspec", "~> 3.2"
|
25
|
-
spec.add_development_dependency "rspec_junit_formatter", "~> 0.3.0"
|
26
|
-
spec.add_development_dependency "webrick", "~> 1.7"
|
27
|
-
|
28
|
-
spec.add_runtime_dependency "concurrent-ruby", "~> 1.0"
|
29
|
-
spec.add_runtime_dependency "http", ">= 4.4.1", "< 6.0.0"
|
30
|
-
end
|
data/scripts/gendocs.sh
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
#!/bin/bash
|
2
|
-
|
3
|
-
# Use this script to generate documentation locally in ./doc so it can be proofed before release.
|
4
|
-
# After release, documentation will be visible at https://www.rubydoc.info/gems/ld-eventsource
|
5
|
-
|
6
|
-
gem install --conservative yard
|
7
|
-
gem install --conservative redcarpet # provides Markdown formatting
|
8
|
-
|
9
|
-
# yard doesn't seem to do recursive directories, even though Ruby's Dir.glob supposedly recurses for "**"
|
10
|
-
PATHS="lib/*.rb lib/**/*.rb lib/**/**/*.rb"
|
11
|
-
|
12
|
-
yard doc --no-private --markup markdown --markup-provider redcarpet --embed-mixins $PATHS - README.md
|