network_resiliency 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/Gemfile.lock +1 -1
- data/lib/network_resiliency/adapter/redis.rb +2 -1
- data/lib/network_resiliency/stats_engine.rb +1 -1
- data/lib/network_resiliency/version.rb +1 -1
- data/lib/network_resiliency.rb +11 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8949456e392f5198caa080238dff62a567114a9386d3a6f575fdb855fd5b5e98
|
4
|
+
data.tar.gz: 95d58f753ccb7f4aa5ffe1093d98d0f5e33016bb7e06caa111a181d29c8ac5fb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d1544a231ebcdd48c6838a8b398f3d4463c9cae2e18182c8e28fda3c4cfeba51b75b6e355342f98a16a51979da035d65040dffdd83e1bcd0273c636f14332236
|
7
|
+
data.tar.gz: a90be5d5152dee3ce23ef7d682ce62dd495293e429d06494e5dcc91eb9cf3bf4a0bcf26b1cece0665815ab181394feff48016c9781e81b69408de3dca1572ec1
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -46,6 +46,7 @@ module NetworkResiliency
|
|
46
46
|
action: "connect",
|
47
47
|
destination: host,
|
48
48
|
max: original_timeout,
|
49
|
+
units: :seconds,
|
49
50
|
)
|
50
51
|
|
51
52
|
attempts = 0
|
@@ -77,7 +78,7 @@ module NetworkResiliency
|
|
77
78
|
destination: host,
|
78
79
|
duration: ts,
|
79
80
|
error: error,
|
80
|
-
timeout: @options[:connect_timeout],
|
81
|
+
timeout: @options[:connect_timeout] * 1_000,
|
81
82
|
attempts: attempts,
|
82
83
|
)
|
83
84
|
end
|
data/lib/network_resiliency.rb
CHANGED
@@ -204,7 +204,7 @@ module NetworkResiliency
|
|
204
204
|
IP_ADDRESS_REGEX.match?(destination)
|
205
205
|
end
|
206
206
|
|
207
|
-
def timeouts_for(adapter:, action:, destination:, max: nil)
|
207
|
+
def timeouts_for(adapter:, action:, destination:, max: nil, units: :ms)
|
208
208
|
default = [ max ]
|
209
209
|
|
210
210
|
return default if NetworkResiliency.mode == :observe
|
@@ -224,6 +224,8 @@ module NetworkResiliency
|
|
224
224
|
timeouts = []
|
225
225
|
|
226
226
|
if max
|
227
|
+
max *= 1_000 if units == :s || units == :seconds
|
228
|
+
|
227
229
|
if p99 < max
|
228
230
|
timeouts << p99
|
229
231
|
|
@@ -262,7 +264,14 @@ module NetworkResiliency
|
|
262
264
|
)
|
263
265
|
end
|
264
266
|
|
265
|
-
|
267
|
+
case units
|
268
|
+
when nil, :ms, :milliseconds
|
269
|
+
timeouts
|
270
|
+
when :s, :seconds
|
271
|
+
timeouts.map { |t| t.to_f / 1_000 if t }
|
272
|
+
else
|
273
|
+
raise ArgumentError, "invalid units: #{units}"
|
274
|
+
end
|
266
275
|
rescue => e
|
267
276
|
NetworkResiliency.statsd&.increment(
|
268
277
|
"network_resiliency.error",
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: network_resiliency
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Pepper
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-11-
|
11
|
+
date: 2023-11-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: byebug
|