sc4ry 0.1.3 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -1
- data/lib/sc4ry/circuits.rb +5 -1
- data/lib/sc4ry/exceptions.rb +6 -1
- data/lib/sc4ry/run_controller.rb +2 -2
- data/lib/sc4ry/version.rb +1 -1
- data/sc4ry.gemspec +5 -0
- metadata +31 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6880abfcd193901a6d55d19df6cfe8ad73f407fc1b58aa078f94e3f31c11042f
|
4
|
+
data.tar.gz: 6a32baa113d73a3f2a76c4df860385296c49382ed4829fdb971e246b79ed1933
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f4471f2769356f0068651aa5d5b4ea218e9a6b0ce608bb76db4ac0bb57f5df1e121df5b912478beea341eadde4f47ddd74c51fd08f651945926b1679d1b19af6
|
7
|
+
data.tar.gz: a2393c0893d3850ad154efdfe54608927f7f567aa65db4c16f7550fe7a9e681b072c3f2ef0a306e9126040dc347e4a0b4c8535fa637113d57aac399671f54f2d
|
data/README.md
CHANGED
@@ -39,16 +39,24 @@ pp Sc4ry::Circuits.list
|
|
39
39
|
# display default config, must be override with a nested hash by calling default_config= method
|
40
40
|
pp Sc4ry::Circuits.default_config
|
41
41
|
|
42
|
+
|
43
|
+
# Config an alternate logger
|
44
|
+
Sc4ry::Logger.register name: :perso, instance: ::Logger.new('/tmp/logfile.log')
|
45
|
+
Sc4ry::Logger::current = :perso
|
46
|
+
|
47
|
+
|
42
48
|
# default values, circuit is half open before one of the max count is reached
|
43
49
|
|
44
50
|
# {:max_failure_count=>5, => maximum failure before opening circuit
|
45
51
|
# :timeout_value=>20, => timeout value, if :timeout => true
|
46
|
-
# :timeout=>false, => activate internal timeout
|
52
|
+
# :timeout=>false, => (de)activate internal timeout
|
47
53
|
# :max_timeout_count=>5, => maximum timeout try before opening circuit
|
48
54
|
# :max_time=>10, => maximum time for a circuit run
|
49
55
|
# :max_overtime_count=>3, => maximum count of overtime before opening circuit
|
50
56
|
# :check_delay=>30, => delay after opening, before trying again to closed circuit or after an other check
|
51
57
|
# :notifiers=>[], => active notifier, must be :symbol in [:prometheus, :mattermost]
|
58
|
+
# :forward_unknown_exceptions => true, => (de)activate forwarding of unknown exceptions, just log in DEBUG if false
|
59
|
+
# :raise_on_opening => false, => (de)activate raise specific Sc4ry exceptions ( CircuitBreaked ) if circuit opening
|
52
60
|
# :exceptions=>[StandardError, RuntimeError]} => list of selected Exceptions considered for failure, others are SKIPPED.
|
53
61
|
|
54
62
|
# display configuration for a specific circuit
|
data/lib/sc4ry/circuits.rb
CHANGED
@@ -20,6 +20,10 @@ module Sc4ry
|
|
20
20
|
return @@config
|
21
21
|
end
|
22
22
|
|
23
|
+
def Circuits.default_config=(config)
|
24
|
+
@@config = config
|
25
|
+
end
|
26
|
+
|
23
27
|
def Circuits.register(options = {})
|
24
28
|
raise ":circuit is mandatory" unless options[:circuit]
|
25
29
|
name = options[:circuit]
|
@@ -89,7 +93,7 @@ module Sc4ry
|
|
89
93
|
data[:status][:general] = status if worst_status.include? status
|
90
94
|
end
|
91
95
|
if save != data[:status][:general] then
|
92
|
-
raise Sc4ry::Exceptions
|
96
|
+
raise Sc4ry::Exceptions::CircuitBreaked if data[:status][:general] == :open and data[:raise_on_opening]
|
93
97
|
Sc4ry::Helpers.notify circuit: options[:circuit], config: data
|
94
98
|
end
|
95
99
|
@@circuits_store.put key: options[:circuit], value: data
|
data/lib/sc4ry/exceptions.rb
CHANGED
data/lib/sc4ry/run_controller.rb
CHANGED
@@ -44,9 +44,9 @@ module Sc4ry
|
|
44
44
|
@failure = true
|
45
45
|
else
|
46
46
|
if @circuit[:forward_unknown_exceptions] then
|
47
|
-
raise
|
47
|
+
raise e.class, "Sc4ry forward: #{e.message}"
|
48
48
|
else
|
49
|
-
Sc4ry::
|
49
|
+
Sc4ry::Helpers.log level: :debug, message: "skipped : #{@last_exception}"
|
50
50
|
end
|
51
51
|
|
52
52
|
end
|
data/lib/sc4ry/version.rb
CHANGED
data/sc4ry.gemspec
CHANGED
@@ -19,4 +19,9 @@ Gem::Specification.new do |spec|
|
|
19
19
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
20
20
|
end
|
21
21
|
spec.require_paths = ["lib"]
|
22
|
+
|
23
|
+
spec.add_dependency "prometheus-client", "~> 3.0"
|
24
|
+
spec.add_dependency "rest-client", "~> 2.1"
|
25
|
+
|
26
|
+
|
22
27
|
end
|
metadata
CHANGED
@@ -1,15 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sc4ry
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Romain GEORGES
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-03-
|
12
|
-
dependencies:
|
11
|
+
date: 2022-03-08 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: prometheus-client
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rest-client
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.1'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.1'
|
13
41
|
description: Sc4ry provide the design pattern Circuit breaker for your application.
|
14
42
|
email:
|
15
43
|
- romain.georges@orange.com
|