network_resiliency 0.6.7 → 0.6.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8cb7405c6ce983981b9eccdc8aa9c2b3b51020fc2ad8f525b5908621a7d5ceec
4
- data.tar.gz: 6baa6fa692dc479082ffaa1805c7dd96e2815ae5bec9ccb6453452d8410c1db3
3
+ metadata.gz: 8380eb51ca287984c7460bcaec21486e9f3b0d659a4938d9d8acba847408455e
4
+ data.tar.gz: 6af73756043d429bbda699f6424385c51487433f759db9a7f5e4e669edfbbd53
5
5
  SHA512:
6
- metadata.gz: 8761514b5a55a983381df650817777c54679e13760c2af4e300b37dedb4ed820aa17b194f85a76b423b0ba0bd0ce645c724e1c10ae45ababaed621403d93ad14
7
- data.tar.gz: a76fe8fc08364042547ff7a78ec13c598829e28e3140cfd462836c396419e29265aefa357874004c8627ff8310fadcc8f571dd0b9bb796508697a191353ebf50
6
+ metadata.gz: 0e926bdcfba052de25ae2556478262ffebc6f484eb7dfd7cc6c2ba718128ba6b2bc8a0327f24a9b1e1a2a6cbf5130ed614465dcb3d79092918d7ae47741a9581
7
+ data.tar.gz: 7a08743fe845c881e80124f8869d82563419ced41adb68ab654e3aad96d88ca5d6b70ae5dace10135a078652207605a7f4df8c39648f9b0a05e700602da78a5b
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ### v0.6.9 (2023-12-07)
2
+ - tag mode
3
+ - request timeout header
4
+
5
+ ### v0.6.8 (2023-12-04)
6
+ - slim metrics
7
+
1
8
  ### v0.6.7 (2023-12-04)
2
9
  - auto patch
3
10
  - adapter stubbing
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- network_resiliency (0.6.7)
4
+ network_resiliency (0.6.9)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -13,9 +13,6 @@ require "network_resiliency"
13
13
 
14
14
  NetworkResiliency.configure do |conf|
15
15
  conf.statsd = Datadog::Statsd.new
16
-
17
- # patch Redis instances
18
- conf.patch :redis
19
16
  end
20
17
 
21
18
  Redis.new.ping
@@ -5,6 +5,8 @@ module NetworkResiliency
5
5
  module HTTP
6
6
  extend self
7
7
 
8
+ REQUEST_TIMEOUT_HEADER = "X-Request-Timeout"
9
+
8
10
  def patch(instance = nil)
9
11
  return if patched?(instance)
10
12
 
@@ -61,9 +63,10 @@ module NetworkResiliency
61
63
  attempts += 1
62
64
  error = nil
63
65
 
64
- set_timeout.call(timeouts.shift)
66
+ timeout = timeouts.shift
67
+ set_timeout.call(timeout)
65
68
 
66
- yield
69
+ yield timeout
67
70
  rescue ::Timeout::Error,
68
71
  defined?(OpenSSL::SSL) ? OpenSSL::OpenSSLError : IOError,
69
72
  SystemCallError => e
@@ -115,7 +118,12 @@ module NetworkResiliency
115
118
 
116
119
  idepotent = Net::HTTP::IDEMPOTENT_METHODS_.include?(req.method)
117
120
 
118
- with_resilience(:request, destination, idepotent) { super }
121
+ with_resilience(:request, destination, idepotent) do |timeout|
122
+ # send timeout via headers
123
+ req[REQUEST_TIMEOUT_HEADER] = timeout
124
+
125
+ super
126
+ end
119
127
  end
120
128
  end
121
129
  end
@@ -1,3 +1,3 @@
1
1
  module NetworkResiliency
2
- VERSION = "0.6.7"
2
+ VERSION = "0.6.9"
3
3
  end
@@ -177,20 +177,11 @@ module NetworkResiliency
177
177
  adapter: adapter,
178
178
  destination: destination,
179
179
  error: error,
180
+ mode: mode(action.to_sym),
180
181
  attempts: (attempts if attempts > 1),
181
182
  }.compact,
182
183
  )
183
184
 
184
- NetworkResiliency.statsd&.distribution(
185
- "network_resiliency.#{action}.magnitude",
186
- duration.order_of_magnitude(ceil: true),
187
- tags: {
188
- adapter: adapter,
189
- destination: destination,
190
- error: error,
191
- }.compact,
192
- )
193
-
194
185
  NetworkResiliency.statsd&.gauge(
195
186
  "network_resiliency.#{action}.timeout",
196
187
  timeout,
@@ -208,18 +199,8 @@ module NetworkResiliency
208
199
  adapter: adapter,
209
200
  destination: destination,
210
201
  },
211
- ) if timeout && timeout > 0
202
+ ) if timeout && timeout > duration
212
203
  else
213
- # track successful retries
214
- NetworkResiliency.statsd&.increment(
215
- "network_resiliency.#{action}.resilient",
216
- tags: {
217
- adapter: adapter,
218
- destination: destination,
219
- attempts: attempts,
220
- },
221
- ) if attempts > 1
222
-
223
204
  # record stats
224
205
  key = [ adapter, action, destination ].join(":")
225
206
  stats = StatsEngine.add(key, duration)
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.6.7
4
+ version: 0.6.9
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-12-04 00:00:00.000000000 Z
11
+ date: 2023-12-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: byebug