faulty 0.8.0 → 0.8.1

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: 815cc1b7ac571e9dc69546efd1b3892795a5ef284cc43448b8a6c1feadcf49c3
4
- data.tar.gz: 575c2e0e7abb413f8866a0e159129a6f1ecc76149e8d8cb97c65c7ffd9913ba9
3
+ metadata.gz: afcc83576fab771e2cbf2c195027ccbe2cf014d437b53355e20fcc411a578995
4
+ data.tar.gz: ccc1fc4bf2fa33599b0295bdd7f65db61cdf17f7a9971418753990f8cc04eea4
5
5
  SHA512:
6
- metadata.gz: 6effebfa578717256dc4ef7ec1c59a5f694eff2c78b21edb1649375a3f7ab62bbad597e3e4a0dc63cd729b4e66b4079ea9cbfd72795a1bfd34a9fab489415847
7
- data.tar.gz: 2ba730eaa396ce24cb9d4eaf3a35db84180eb5c8ba4e3f3bc803d389436870480bd542aa57c93089ef33b77afe3f9b0c8614f972d232b971d8310f2dd067eb39
6
+ metadata.gz: f9ee287057df37f330e05e09b90b68e69325cc934f074db5746851bb16eecf2624b3d2689520d052f1af6c73c6f1f08ef1c0ef61c31bd2cc0236647f400dba41
7
+ data.tar.gz: ae88dedd7eff9153e84a47434d19731d371aae19e036dc88fb338945cd26330c443002fa5b2141fddf4b8c35e4dc927d4f3d4e2d4749c1241a1c1deb6024bd9e
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## Releae v0.8.1
2
+
3
+ * Add cause message to CircuitTrippedError #40 justinhoward
4
+ * Record failures for cache hits #41 justinhoward
5
+
6
+
1
7
  ## Release v0.8.0
2
8
 
3
9
  * Store circuit options in the backend when run #34 justinhoward
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 uses adapters to auto-wire circuits, and it has
1292
- only in-memory storage by design.
1293
- - [circuitbox](https://github.com/yammer/circuitbox): Similar in design to
1294
- Faulty, but with a different API. It uses Moneta to abstract circuit storage
1295
- to allow any key-value store.
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 "Starting circuit benchmarks with #{n} iterations each\n\n"
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 = 1_000_000
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
- puts "\n\nStarting extra benchmarks with #{n} iterations each\n\n"
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
- Benchmark.bm(25) do |b|
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))
@@ -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
- raise options.error_module::CircuitTrippedError.new(nil, self) if failure!(status, e)
402
-
403
- raise options.error_module::CircuitFailureError.new(nil, self)
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
- message ||= %(circuit error for "#{circuit.name}")
40
- @circuit = circuit
39
+ full_message = %(circuit error for "#{circuit.name}")
40
+ full_message = %(#{full_message}: #{message}) if message
41
41
 
42
- super(message)
42
+ @circuit = circuit
43
+ super(full_message)
43
44
  end
44
45
  end
45
46
 
@@ -3,6 +3,6 @@
3
3
  class Faulty
4
4
  # The current Faulty version
5
5
  def self.version
6
- Gem::Version.new('0.8.0')
6
+ Gem::Version.new('0.8.1')
7
7
  end
8
8
  end
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.0
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-14 00:00:00.000000000 Z
11
+ date: 2021-09-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby