network_resiliency 0.4.0 → 0.4.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c372873056610bf21197e55a265bdfd03e200b064c727a4713ea8725ae3d696d
4
- data.tar.gz: 5da4933543bf9a57d46ed4a3b4d94a692524e641f6c1293d8bcb99aa74c0c9d9
3
+ metadata.gz: 8949456e392f5198caa080238dff62a567114a9386d3a6f575fdb855fd5b5e98
4
+ data.tar.gz: 95d58f753ccb7f4aa5ffe1093d98d0f5e33016bb7e06caa111a181d29c8ac5fb
5
5
  SHA512:
6
- metadata.gz: b8e9b66cb83ff5bfda080c43935e8834228cfbd16afd0c1229be2b7edbea8469702d917ae7b6bb7383b774ebf68802e9a5572ee89357723d479d1dd8b3a91f2c
7
- data.tar.gz: 68f241f0bd9b7ef5b0b291e2e1be11aa3d2c377f6b4b70552ba32638122bff300bc1252b279a13c41e96af3ffa8843bc571b74bd9aac7f1300f27472e18001ff
6
+ metadata.gz: d1544a231ebcdd48c6838a8b398f3d4463c9cae2e18182c8e28fda3c4cfeba51b75b6e355342f98a16a51979da035d65040dffdd83e1bcd0273c636f14332236
7
+ data.tar.gz: a90be5d5152dee3ce23ef7d682ce62dd495293e429d06494e5dcc91eb9cf3bf4a0bcf26b1cece0665815ab181394feff48016c9781e81b69408de3dca1572ec1
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ### v0.4.1 (2023-11-14)
2
+ - timeout units
3
+
1
4
  ### v0.4.0 (2023-11-13)
2
5
  - redis resiliency
3
6
  - timeouts_for
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- network_resiliency (0.4.0)
4
+ network_resiliency (0.4.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -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
@@ -31,7 +31,7 @@ module NetworkResiliency
31
31
 
32
32
  # select data to be synced
33
33
  data = synchronize do
34
- # ensure sync is not run concurrently
34
+ # ensure sync does not run concurrently
35
35
  return [] if @syncing
36
36
  @syncing = Thread.current
37
37
 
@@ -1,3 +1,3 @@
1
1
  module NetworkResiliency
2
- VERSION = "0.4.0"
2
+ VERSION = "0.4.1"
3
3
  end
@@ -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
- timeouts
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.0
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-13 00:00:00.000000000 Z
11
+ date: 2023-11-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: byebug