network_resiliency 0.6.1 → 0.6.2

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: a94a624ababefe0045c52a57be145826d8072f8367d494afdef4892eb81af066
4
- data.tar.gz: dc1412ead0b212c14d1707236cb76b5d19935ab6d9562cee01ef6a761c70bcb5
3
+ metadata.gz: 5a2741f43768bd43985efdbf000fc82075d8fb2757e6af19a7ab0aeeae2f3a87
4
+ data.tar.gz: 713af5ee87ca4a8149a3ce3f5d9416eb2fa03cc0bdea7aca1828e18a59595003
5
5
  SHA512:
6
- metadata.gz: 2db8772835afb0358179255e94960499fbfa4bcebcd6bba532e38a0a533b658e9dfd2a94a12de5d7ef29aef372d671e14d04a226b19acddc1621d80617056d7a
7
- data.tar.gz: b9aa489ff41eecde7aa9bee4e0b8377a8952827dff9a0911272d987bd487fb4b5bdcde02974414bc6ad25b7c6490585282baa4dd189e66a76d5b549743af088f
6
+ metadata.gz: 6d80cac5009c100449adec47f70636dc015b069dbd6e3901545f6378841de9ad8970b2156d948c4e9ff4deb1cb579141167078032af6faa88270d88566f592e0
7
+ data.tar.gz: 7a9f01e6967657f61a40d80755d95f1c67387f598bfa73efb6d3d6f38661a7e17e5ccdf058834e3e8b09ba89bdb0d286019a4c3832b4d54908d044f5db9565e9
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ### v0.6.2 (2023-11-26)
2
+ - syncer
3
+ - redis without_reconnect
4
+
1
5
  ### v0.6.1 (2023-11-21)
2
6
  - bugfix
3
7
  - redis system errors
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- network_resiliency (0.6.1)
4
+ network_resiliency (0.6.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -82,7 +82,7 @@ module NetworkResiliency
82
82
 
83
83
  @options[timeout_key] = timeouts.shift
84
84
 
85
- yield
85
+ without_reconnect { yield }
86
86
  rescue ::Redis::BaseConnectionError, SystemCallError => e
87
87
  # capture error
88
88
 
@@ -0,0 +1,39 @@
1
+ module NetworkResiliency
2
+ class Syncer < Thread
3
+ class << self
4
+ def start(redis)
5
+ @instance&.shutdown
6
+ @instance = new(redis)
7
+ end
8
+
9
+ def stop
10
+ @instance&.shutdown
11
+ @instance = nil
12
+ end
13
+ end
14
+
15
+ def initialize(redis)
16
+ @redis = redis
17
+
18
+ super { sync }
19
+ end
20
+
21
+ def shutdown
22
+ @shutdown = true
23
+
24
+ # prevent needless delay
25
+ raise Interrupt if status == "sleep"
26
+ end
27
+
28
+ private
29
+
30
+ def sync
31
+ until @shutdown
32
+ StatsEngine.sync(@redis)
33
+
34
+ sleep(3)
35
+ end
36
+ rescue Interrupt
37
+ end
38
+ end
39
+ end
@@ -1,3 +1,3 @@
1
1
  module NetworkResiliency
2
- VERSION = "0.6.1"
2
+ VERSION = "0.6.2"
3
3
  end
@@ -1,6 +1,7 @@
1
1
  require "network_resiliency/refinements"
2
2
  require "network_resiliency/stats"
3
3
  require "network_resiliency/stats_engine"
4
+ require "network_resiliency/syncer"
4
5
  require "network_resiliency/version"
5
6
 
6
7
  using NetworkResiliency::Refinements
@@ -24,7 +25,7 @@ module NetworkResiliency
24
25
  def configure
25
26
  yield self if block_given?
26
27
 
27
- start_syncing if redis
28
+ Syncer.start(redis) if redis
28
29
  end
29
30
 
30
31
  def patch(*adapters)
@@ -292,11 +293,7 @@ module NetworkResiliency
292
293
  @mode = nil
293
294
  Thread.current["network_resiliency"] = nil
294
295
  StatsEngine.reset
295
-
296
- if @sync_worker
297
- @sync_worker.kill
298
- @sync_worker = nil
299
- end
296
+ Syncer.stop
300
297
  end
301
298
 
302
299
  # private
@@ -304,18 +301,4 @@ module NetworkResiliency
304
301
  def thread_state
305
302
  Thread.current["network_resiliency"] ||= {}
306
303
  end
307
-
308
- def start_syncing
309
- @sync_worker.kill if @sync_worker
310
-
311
- raise "Redis not configured" unless redis
312
-
313
- @sync_worker = Thread.new do
314
- loop do
315
- StatsEngine.sync(redis)
316
-
317
- sleep(3)
318
- end
319
- end
320
- end
321
304
  end
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.1
4
+ version: 0.6.2
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-21 00:00:00.000000000 Z
11
+ date: 2023-11-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: byebug
@@ -198,6 +198,7 @@ files:
198
198
  - lib/network_resiliency/refinements.rb
199
199
  - lib/network_resiliency/stats.rb
200
200
  - lib/network_resiliency/stats_engine.rb
201
+ - lib/network_resiliency/syncer.rb
201
202
  - lib/network_resiliency/version.rb
202
203
  - network_resiliency.gemspec
203
204
  homepage: https://github.com/dpep/network_resiliency_rb