ld-eventsource 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/Gemfile.lock +1 -1
- data/lib/ld-eventsource/impl/backoff.rb +0 -4
- data/lib/ld-eventsource/version.rb +1 -1
- data/spec/backoff_spec.rb +50 -0
- data/spec/client_spec.rb +2 -2
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8af7db395f6a4a500ea56ff3f742aab25b8ca416
|
4
|
+
data.tar.gz: ee59c90efdf456e277a6f6ea7209a62941dbe96b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c1c5e63d0f8bcff6c27a60f9a8cb04f5d1ffc3e4128bc5d9822f19663934b70ab3f90725ba747b4e13cc77c154c8d23605ed677c392dab980fd56c3d87d8cef
|
7
|
+
data.tar.gz: eec5bfce676d858bca4d8c687c043d45f2e200d3fb8819d693e81812e5504f597fcbed9bbe011d29f4aba967ee17de1e1302b3b673fbb5d2b9af03ba6558a823
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,11 @@
|
|
2
2
|
|
3
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
4
|
|
5
|
+
## [1.0.2] - 2020-03-10
|
6
|
+
### Removed:
|
7
|
+
- Removed an unused dependency on `rake`. There are no other changes in this release.
|
8
|
+
|
9
|
+
|
5
10
|
## [1.0.1] - 2019-07-10
|
6
11
|
### Fixed:
|
7
12
|
- 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>`.
|
data/Gemfile.lock
CHANGED
@@ -38,10 +38,6 @@ module SSE
|
|
38
38
|
good_duration = Time.now.to_f - @last_good_time
|
39
39
|
@attempts = 0 if good_duration >= @reconnect_reset_interval
|
40
40
|
end
|
41
|
-
if @attempts == 0
|
42
|
-
@attempts += 1
|
43
|
-
return 0
|
44
|
-
end
|
45
41
|
@last_good_time = nil
|
46
42
|
target = ([@base_interval * (2 ** @attempts), @max_interval].min).to_f
|
47
43
|
@attempts += 1
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require "ld-eventsource"
|
2
|
+
|
3
|
+
module SSE
|
4
|
+
module Impl
|
5
|
+
describe Backoff do
|
6
|
+
it "increases exponentially with jitter" do
|
7
|
+
initial = 1.5
|
8
|
+
max = 60
|
9
|
+
b = Backoff.new(initial, max)
|
10
|
+
previous = 0
|
11
|
+
|
12
|
+
for i in 1..6 do
|
13
|
+
interval = b.next_interval
|
14
|
+
expect(interval).to be > previous
|
15
|
+
target = initial * (2 ** (i - 1))
|
16
|
+
expect(interval).to be <= target
|
17
|
+
expect(interval).to be >= target / 2
|
18
|
+
previous = i
|
19
|
+
end
|
20
|
+
|
21
|
+
interval = b.next_interval
|
22
|
+
expect(interval).to be >= previous
|
23
|
+
expect(interval).to be <= max
|
24
|
+
end
|
25
|
+
|
26
|
+
it "resets to initial delay if reset threshold has elapsed" do
|
27
|
+
initial = 1.5
|
28
|
+
max = 60
|
29
|
+
threshold = 2
|
30
|
+
b = Backoff.new(initial, max, reconnect_reset_interval: threshold)
|
31
|
+
|
32
|
+
for i in 1..6 do
|
33
|
+
# just cause the backoff to increase quickly, don't actually do these delays
|
34
|
+
b.next_interval
|
35
|
+
end
|
36
|
+
|
37
|
+
b.mark_success
|
38
|
+
sleep(threshold + 0.001)
|
39
|
+
|
40
|
+
interval = b.next_interval
|
41
|
+
expect(interval).to be <= initial
|
42
|
+
expect(interval).to be >= initial / 2
|
43
|
+
|
44
|
+
interval = b.next_interval # make sure it continues increasing after that
|
45
|
+
expect(interval).to be <= (initial * 2)
|
46
|
+
expect(interval).to be >= initial
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
data/spec/client_spec.rb
CHANGED
@@ -330,7 +330,7 @@ EOT
|
|
330
330
|
expect(event_sink.pop).to eq(simple_event_1)
|
331
331
|
if i > 0
|
332
332
|
interval = request_times[i] - request_end_times[i - 1]
|
333
|
-
expect(interval).to be <= initial_interval
|
333
|
+
expect(interval).to be <= (initial_interval + 0.1)
|
334
334
|
end
|
335
335
|
end
|
336
336
|
end
|
@@ -362,7 +362,7 @@ EOT
|
|
362
362
|
with_client(client) do |client|
|
363
363
|
expect(event_sink.pop).to eq(simple_event_1)
|
364
364
|
interval = request_times[1] - request_times[0]
|
365
|
-
expect(interval).to be <
|
365
|
+
expect(interval).to be < 0.5
|
366
366
|
end
|
367
367
|
end
|
368
368
|
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: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- LaunchDarkly
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-03-
|
11
|
+
date: 2020-03-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -120,6 +120,7 @@ files:
|
|
120
120
|
- lib/ld-eventsource/version.rb
|
121
121
|
- scripts/gendocs.sh
|
122
122
|
- scripts/release.sh
|
123
|
+
- spec/backoff_spec.rb
|
123
124
|
- spec/client_spec.rb
|
124
125
|
- spec/event_parser_spec.rb
|
125
126
|
- spec/http_stub.rb
|
@@ -149,6 +150,7 @@ signing_key:
|
|
149
150
|
specification_version: 4
|
150
151
|
summary: LaunchDarkly SSE client
|
151
152
|
test_files:
|
153
|
+
- spec/backoff_spec.rb
|
152
154
|
- spec/client_spec.rb
|
153
155
|
- spec/event_parser_spec.rb
|
154
156
|
- spec/http_stub.rb
|