simple_circuit_breaker 0.2.2 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- ZDI0YTBhYjI4NTg5MDg3N2Q3N2EyNzIyOTcwNGVlZjVjNDA5NmZlYg==
5
- data.tar.gz: !binary |-
6
- NDNhYmNkZTM4ZjI3OWQ0YmQ0OWU4YmJlNzM3ZTM1YjA5NWNjNTcwOQ==
2
+ SHA1:
3
+ metadata.gz: 559cc63d618ac27290b6fd0470f96b8c1070cb25
4
+ data.tar.gz: e1935e6e411e44e4024fd4d73d6f9048b9268e9f
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- OTQzMTViNjQ4NTg1YmE0OGE5OTBhNGUwYTYwNzMyNWIxN2FiNGY3Y2MzYmU4
10
- N2Y5NjFlYTgyOTRkYmIwMjEwMTk4YTk0MThiYjc4ZjBmNWYxODlmZmNiMDM3
11
- OTQ3YjUyMjUyZTUxZjAxYzIxY2UyYmZlYzVjNjM3NGJiMDU2MTk=
12
- data.tar.gz: !binary |-
13
- NWY5ZjBjMDM4ZDA5MTk4YTY4YWFhMWM4MDVjODkzMDBmYWM0YzE5YThkMTFh
14
- MWM1ZjEwZjYyZjUxNWI5ZmJjZTcwYjhmYTM3ZDliOTAyOTlkYjgxYTdjY2Yw
15
- ZmUwN2JkYjMwNzlkMDg3ZjM2YjBhNDNkY2U4ZjgwZTM5ODQ3NjM=
6
+ metadata.gz: a213fc1fa7df35707ac1d6521fa4953543d8bfa8c9f431e2b939c5c90c95e8ac555ff6beb271ffa477c2f7ae24332c51fa2f605ce97dc85a27d2e7de821c9ede
7
+ data.tar.gz: dd109e67594d0df104ad183495b14d818b2f4206737633529a68337ee12a454382e0a968f4c919bbbd9f8d221050b62fc1c359a832678737ca905b1c699feb0c
@@ -1,5 +1,5 @@
1
1
  class SimpleCircuitBreaker
2
- VERSION = '0.2.2'
2
+ VERSION = '0.3.0'
3
3
 
4
4
  class CircuitOpenError < StandardError
5
5
  end
@@ -26,8 +26,8 @@ protected
26
26
  result = yield
27
27
  reset!
28
28
  result
29
- rescue Exception => exception
30
- if exceptions.empty? || exceptions.include?(exception.class)
29
+ rescue Exception => e
30
+ if exceptions.empty? || exceptions.any? { |exception| e.class <= exception }
31
31
  fail!
32
32
  end
33
33
  raise
@@ -71,6 +71,23 @@ describe SimpleCircuitBreaker do
71
71
  end.must_raise SimpleCircuitBreaker::CircuitOpenError
72
72
  end
73
73
 
74
+ it 'opens after 3 consecutive failures for subclasses of a handled exception' do
75
+ subclass = Class.new(StandardError)
76
+
77
+ 3.times do
78
+ begin
79
+ @breaker.handle(StandardError) { raise subclass }
80
+ rescue subclass
81
+ end
82
+ end
83
+
84
+ Proc.new do
85
+ @breaker.handle(StandardError) do
86
+ raise subclass
87
+ end
88
+ end.must_raise SimpleCircuitBreaker::CircuitOpenError
89
+ end
90
+
74
91
  it 'doesn\'t open after 3 consecutive failures for non-handled exception' do
75
92
  class FooError < Exception
76
93
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_circuit_breaker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julius Volz
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-09-21 00:00:00.000000000 Z
12
+ date: 2016-01-22 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Simple Ruby implementation of the Circuit Breaker design pattern
15
15
  email: julius@soundcloud.com ts@soundcloud.com
@@ -17,7 +17,7 @@ executables: []
17
17
  extensions: []
18
18
  extra_rdoc_files: []
19
19
  files:
20
- - .travis.yml
20
+ - ".travis.yml"
21
21
  - LICENSE
22
22
  - README.md
23
23
  - Rakefile
@@ -34,20 +34,19 @@ require_paths:
34
34
  - lib
35
35
  required_ruby_version: !ruby/object:Gem::Requirement
36
36
  requirements:
37
- - - ! '>='
37
+ - - ">="
38
38
  - !ruby/object:Gem::Version
39
39
  version: '1.9'
40
40
  required_rubygems_version: !ruby/object:Gem::Requirement
41
41
  requirements:
42
- - - ! '>='
42
+ - - ">="
43
43
  - !ruby/object:Gem::Version
44
44
  version: '0'
45
45
  requirements: []
46
46
  rubyforge_project:
47
- rubygems_version: 2.1.11
47
+ rubygems_version: 2.5.1
48
48
  signing_key:
49
49
  specification_version: 4
50
50
  summary: Ruby Circuit Breaker implementation
51
51
  test_files:
52
52
  - test/simple_circuit_breaker_test.rb
53
- has_rdoc: