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 +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +1 -1
- data/lib/network_resiliency/adapter/redis.rb +1 -1
- data/lib/network_resiliency/syncer.rb +39 -0
- data/lib/network_resiliency/version.rb +1 -1
- data/lib/network_resiliency.rb +3 -20
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5a2741f43768bd43985efdbf000fc82075d8fb2757e6af19a7ab0aeeae2f3a87
|
4
|
+
data.tar.gz: 713af5ee87ca4a8149a3ce3f5d9416eb2fa03cc0bdea7aca1828e18a59595003
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6d80cac5009c100449adec47f70636dc015b069dbd6e3901545f6378841de9ad8970b2156d948c4e9ff4deb1cb579141167078032af6faa88270d88566f592e0
|
7
|
+
data.tar.gz: 7a9f01e6967657f61a40d80755d95f1c67387f598bfa73efb6d3d6f38661a7e17e5ccdf058834e3e8b09ba89bdb0d286019a4c3832b4d54908d044f5db9565e9
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -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
|
data/lib/network_resiliency.rb
CHANGED
@@ -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
|
-
|
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.
|
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-
|
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
|