faulty 0.8.0 → 0.8.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 +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +7 -5
- data/bin/benchmark +30 -7
- data/lib/faulty/circuit.rb +6 -3
- data/lib/faulty/error.rb +4 -3
- data/lib/faulty/version.rb +1 -1
- 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: afcc83576fab771e2cbf2c195027ccbe2cf014d437b53355e20fcc411a578995
|
4
|
+
data.tar.gz: ccc1fc4bf2fa33599b0295bdd7f65db61cdf17f7a9971418753990f8cc04eea4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f9ee287057df37f330e05e09b90b68e69325cc934f074db5746851bb16eecf2624b3d2689520d052f1af6c73c6f1f08ef1c0ef61c31bd2cc0236647f400dba41
|
7
|
+
data.tar.gz: ae88dedd7eff9153e84a47434d19731d371aae19e036dc88fb338945cd26330c443002fa5b2141fddf4b8c35e4dc927d4f3d4e2d4749c1241a1c1deb6024bd9e
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1288,11 +1288,12 @@ but there are and have been many other options:
|
|
1288
1288
|
### Currently Active
|
1289
1289
|
|
1290
1290
|
- [semian](https://github.com/Shopify/semian): A resiliency toolkit that
|
1291
|
-
includes circuit breakers. It
|
1292
|
-
only in-memory storage by design.
|
1293
|
-
|
1294
|
-
|
1295
|
-
to
|
1291
|
+
includes circuit breakers. It auto-wires circuits for MySQL, Net::HTTP, and
|
1292
|
+
Redis. It has only in-memory storage by design. Its core components are
|
1293
|
+
written in C, which allows it to be faster than pure ruby.
|
1294
|
+
- [circuitbox](https://github.com/yammer/circuitbox): Also uses a block syntax
|
1295
|
+
to manually define circuits. It uses Moneta to abstract circuit storage to
|
1296
|
+
allow any key-value store.
|
1296
1297
|
|
1297
1298
|
### Previous Work
|
1298
1299
|
|
@@ -1309,6 +1310,7 @@ but there are and have been many other options:
|
|
1309
1310
|
|
1310
1311
|
- Simple API but configurable for advanced users
|
1311
1312
|
- Pluggable storage backends (circuitbox also has this)
|
1313
|
+
- Patches for common core dependencies (semian also has this)
|
1312
1314
|
- Protected storage access with fallback to safe storage
|
1313
1315
|
- Global, or object-oriented configuration with multiple instances
|
1314
1316
|
- Integrated caching support tailored for fault-tolerance
|
data/bin/benchmark
CHANGED
@@ -4,12 +4,13 @@
|
|
4
4
|
require 'bundler/setup'
|
5
5
|
require 'benchmark'
|
6
6
|
require 'faulty'
|
7
|
+
require 'redis'
|
8
|
+
require 'json'
|
7
9
|
|
8
10
|
n = 100_000
|
9
|
-
|
10
|
-
puts "
|
11
|
-
|
12
|
-
Benchmark.bm(25) do |b|
|
11
|
+
width = 25
|
12
|
+
puts "In memory circuits x#{n}"
|
13
|
+
Benchmark.bm(width) do |b|
|
13
14
|
in_memory = Faulty.new(listeners: [])
|
14
15
|
b.report('memory storage') do
|
15
16
|
n.times { in_memory.circuit(:memory).run { true } }
|
@@ -31,11 +32,33 @@ Benchmark.bm(25) do |b|
|
|
31
32
|
end
|
32
33
|
end
|
33
34
|
|
34
|
-
n =
|
35
|
+
n = 1000
|
36
|
+
puts "\n\Redis circuits x#{n}"
|
37
|
+
Benchmark.bm(width) do |b|
|
38
|
+
redis = Faulty.new(listeners: [], storage: Faulty::Storage::Redis.new)
|
39
|
+
b.report('redis storage') do
|
40
|
+
n.times { redis.circuit(:memory).run { true } }
|
41
|
+
end
|
35
42
|
|
36
|
-
|
43
|
+
b.report('redis storage failures') do
|
44
|
+
n.times do
|
45
|
+
begin
|
46
|
+
redis.circuit(:memory_fail, sample_threshold: n + 1).run { raise 'fail' }
|
47
|
+
rescue StandardError
|
48
|
+
# Expected to raise here
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
37
52
|
|
38
|
-
|
53
|
+
redis_large = Faulty.new(listeners: [], storage: Faulty::Storage::Redis.new(max_sample_size: 1000))
|
54
|
+
b.report('large redis storage') do
|
55
|
+
n.times { redis_large.circuit(:memory).run { true } }
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
n = 1_000_000
|
60
|
+
puts "\n\nExtra x#{n}"
|
61
|
+
Benchmark.bm(width) do |b|
|
39
62
|
in_memory = Faulty.new(listeners: [])
|
40
63
|
|
41
64
|
log_listener = Faulty::Events::LogListener.new(Logger.new(File::NULL))
|
data/lib/faulty/circuit.rb
CHANGED
@@ -397,10 +397,13 @@ class Faulty
|
|
397
397
|
rescue *options.errors => e
|
398
398
|
raise if options.exclude.any? { |ex| e.is_a?(ex) }
|
399
399
|
|
400
|
+
opened = failure!(status, e)
|
400
401
|
if cached_value.nil?
|
401
|
-
|
402
|
-
|
403
|
-
|
402
|
+
if opened
|
403
|
+
raise options.error_module::CircuitTrippedError.new(e.message, self)
|
404
|
+
else
|
405
|
+
raise options.error_module::CircuitFailureError.new(e.message, self)
|
406
|
+
end
|
404
407
|
else
|
405
408
|
cached_value
|
406
409
|
end
|
data/lib/faulty/error.rb
CHANGED
@@ -36,10 +36,11 @@ class Faulty
|
|
36
36
|
# @param message [String]
|
37
37
|
# @param circuit [Circuit] The circuit that raised the error
|
38
38
|
def initialize(message, circuit)
|
39
|
-
|
40
|
-
|
39
|
+
full_message = %(circuit error for "#{circuit.name}")
|
40
|
+
full_message = %(#{full_message}: #{message}) if message
|
41
41
|
|
42
|
-
|
42
|
+
@circuit = circuit
|
43
|
+
super(full_message)
|
43
44
|
end
|
44
45
|
end
|
45
46
|
|
data/lib/faulty/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: faulty
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Howard
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-09-
|
11
|
+
date: 2021-09-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|