circuit_breaker-ruby 0.1.1 → 0.1.2
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
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
N2RmNmY0NDYzZWUwZjBjODdhMTU1MjQzNDJiYjg4NGNmMGUzOWE2Yw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MDA3MGE3MzM5YTgxYjJjZGIzMjdlNTRjOTQyNThlYmNlZGVhOThlMg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YjEzNzJhODgzNjNjOTY4ZDBiOGUxNTM2ODUxYjJlNzI3YzNmNjY4NzQ3YTEw
|
10
|
+
ZDRmYzYxMmZmNzUxNjA4NDZiOWFlYzI2M2U4MDJlYmRjMTJlYjZiYzY0ZjA1
|
11
|
+
MWZmODY5MTI3ZTExMGZiZGVmYWIzZTQxZTUxODJmNjFmMzhlYmI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZTJhOGZjYTQ0ZGYxNzA1MTNkYzI3NTgzYzRjZmM2ZTI2NDdkYWFhZmZjZWFm
|
14
|
+
ZjgwNThkZjUwOTdiOGRlODc2ZDVmOTI3N2RhNDk0NWQ5NzUyZDk0MWU0NjQ0
|
15
|
+
NzQ4NDQxZDU5MGRkODVjYmFhNTkyODVjMWY3YjE0MDNlZjc5YjY=
|
data/README.md
CHANGED
@@ -1,4 +1,7 @@
|
|
1
1
|
## Circuit Breaker
|
2
|
+
[](http://rubygems.org/gems/circuit_breaker-ruby)
|
3
|
+
[](https://travis-ci.org/scripbox/circuit_breaker-ruby)
|
4
|
+
|
2
5
|
A circuit breaker which terminates a connection or block of code from executing when it reaches the failure threshold and a percentage. Also it gets reset when a connection succeeds. It also keeps monitoring if connections are working again by checking if it has attained a time to retry.
|
3
6
|
|
4
7
|
## Installation
|
@@ -3,7 +3,7 @@ require './lib/circuit_breaker-ruby/version'
|
|
3
3
|
Gem::Specification.new do |gem|
|
4
4
|
gem.name = 'circuit_breaker-ruby'
|
5
5
|
gem.version = CircuitBreaker::VERSION
|
6
|
-
gem.date = '2016-
|
6
|
+
gem.date = '2016-09-09'
|
7
7
|
gem.summary = 'Circuit breaker for ruby'
|
8
8
|
gem.description = 'Self-resetting breaker retries the protected call after a suitable interval, and it also resets when the call succeeds.'
|
9
9
|
gem.author = 'Scripbox'
|
@@ -5,6 +5,13 @@ module CircuitBreaker
|
|
5
5
|
INVOCATION_TIMEOUT = 10
|
6
6
|
RETRY_TIMEOUT = 60
|
7
7
|
|
8
|
+
UPDATABLE = [
|
9
|
+
:invocation_timeout,
|
10
|
+
:failure_threshold,
|
11
|
+
:failure_threshold_percentage,
|
12
|
+
:retry_timeout
|
13
|
+
]
|
14
|
+
|
8
15
|
attr_accessor :invocation_timeout, :failure_threshold, :failure_threshold_percentage, :retry_timeout
|
9
16
|
|
10
17
|
def initialize
|
@@ -22,7 +22,15 @@ module CircuitBreaker
|
|
22
22
|
CircuitBreaker.config
|
23
23
|
end
|
24
24
|
|
25
|
-
def
|
25
|
+
def update_config!(options)
|
26
|
+
(CircuitBreaker::Config::UPDATABLE & options.keys).each do |variable|
|
27
|
+
instance_variable_set("@#{variable}", options[variable])
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def protect(options = {}, &block)
|
32
|
+
update_config!(options)
|
33
|
+
|
26
34
|
case prev_state = state
|
27
35
|
when States::CLOSED, States::HALF_OPEN
|
28
36
|
connect(&block).tap { update_total_count(prev_state) }
|
@@ -47,4 +47,12 @@ describe CircuitBreaker::Shield do
|
|
47
47
|
raise_error(CircuitBreaker::Open)
|
48
48
|
)
|
49
49
|
end
|
50
|
+
|
51
|
+
context '#protect' do
|
52
|
+
it 'update invocation_timeout in config' do
|
53
|
+
circuit_breaker_shield.protect(invocation_timeout: 20) {}
|
54
|
+
|
55
|
+
expect(circuit_breaker_shield.invocation_timeout).to be(20)
|
56
|
+
end
|
57
|
+
end
|
50
58
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: circuit_breaker-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Scripbox
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-09-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|