circuit_breakage 0.1.2 → 0.1.3

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
  SHA1:
3
- metadata.gz: 9026fcf0d50eb38007dd97047ae181393d29a68b
4
- data.tar.gz: ab1c9b2050bb6e6293e3347ce40fe5588ccbe179
3
+ metadata.gz: b436b7a83a4e4470cf5bf209e276afa440eea28d
4
+ data.tar.gz: bbf480897ba2a7db87096a939b505617bdaccb17
5
5
  SHA512:
6
- metadata.gz: 7627acaac4f74fd5988531384648f43a35d27a3029e1342ea1b140a57a22f7dd31322162b918d8c5339d9ef655118c62020eed1f9c476dd2ed4f9aedbb759c02
7
- data.tar.gz: c27a067b42074c300fbd4fc94e8f3d77d4f0a9ef7dc5bf2b4a4df5e66e646eea108a27920f9e8d18891f9c9b89f84df81de095f81a41b89ea2f24c261cf09c23
6
+ metadata.gz: dacf62b792eadf2d5c9589eb221a028f5e597a071362374357e200c5c0a41b33313243e99851fd9daa8d654aab52228d754350354d04e68afaaddf821e84de48
7
+ data.tar.gz: 77455e880e39b757d046a11fb1e6cfe1394a88a947601a5b8adbbf8c55883b3dd5000b236485cdc5e696b7d971e507cff1a81b04e7935f7551e4b9f7e46121f6
data/README.md CHANGED
@@ -1,9 +1,12 @@
1
1
  # CircuitBreakage
2
2
 
3
3
  A simple Circuit Breaker implementation in Ruby with a timeout. A Circuit
4
- Breaker wraps potentially troublesome logic and will "trip" the circuit (ie,
5
- stop trying to run the logic) if it sees too many failures. After a while, it
6
- will retry.
4
+ Breaker wraps a potentially troublesome block of code and will "trip" the
5
+ circuit (ie, stop trying to run the code) if it sees too many failures. After
6
+ a configurable amount of time, the circuit breaker will retry.
7
+
8
+ See http://martinfowler.com/bliki/CircuitBreaker.html for a more complete
9
+ description of the pattern.
7
10
 
8
11
  ## Usage
9
12
 
@@ -28,6 +31,9 @@ rescue CircuitBreaker::CircuitTimeout
28
31
  end
29
32
  ```
30
33
 
34
+ A "failure" in this context means that the block either raised an exception or
35
+ timed out.
36
+
31
37
  ### Redis-backed "Shared" Circuit Breakers
32
38
 
33
39
  The unique feature of this particular Circuit Breaker gem is that it also
@@ -42,8 +48,19 @@ the retry timer as appropriate.
42
48
 
43
49
  ```ruby
44
50
  connection = some_redis_connection
45
- key = 'my_app/some_operation'
51
+ key = 'my_app/this_operation'
46
52
 
47
53
  breaker = CircuitBreakage::RedisBackedBreaker.new(connection, key, block)
54
+ breaker.lock_timeout = 30 # seconds before assuming a locking process has crashed
55
+
48
56
  # Everything else is the same as above.
49
57
  ```
58
+
59
+ The `lock_timeout` setting is necessary since a process that crashes or is
60
+ killed might be holding the retry lock. This sets the amount of time other
61
+ processes will wait before deciding a lock has expired. It should be longer
62
+ than the amount of time you expect the block to take to run.
63
+
64
+ All circuit breakers using the same key and the same Redis instance will share
65
+ their state . It is strongly recommended that their settings
66
+ (failure_threshold, duration, etc) all be configured the same!
@@ -1,5 +1,3 @@
1
1
  require "circuit_breakage/version"
2
-
3
- module CircuitBreakage
4
- # Your code goes here...
5
- end
2
+ require "circuit_breakage/breaker"
3
+ require "circuit_breakage/redis_backed_breaker"
@@ -1,3 +1,3 @@
1
1
  module CircuitBreakage
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: circuit_breakage
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Hyland