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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9cc6197c11f5b2946c2a7d7ac2057de82866228b4628f5b2d3c0613a3c821ca2
4
- data.tar.gz: 306af4cfc3217b7ccc174b9f93407a995faad9fd691b83b0c6848a620313647f
3
+ metadata.gz: 6880abfcd193901a6d55d19df6cfe8ad73f407fc1b58aa078f94e3f31c11042f
4
+ data.tar.gz: 6a32baa113d73a3f2a76c4df860385296c49382ed4829fdb971e246b79ed1933
5
5
  SHA512:
6
- metadata.gz: d501193d93a2c0fca6db0b0d7429ff00510253f741347a03a6c6b26b872acb24cb14490ea8a9a61e8b768fce541fbda8c56555e2ba940a1bebe225c4b9065c9b
7
- data.tar.gz: e7416163124dee124d7573f37cd2ef51f7d8152105727d057256b5b6738435ab28949c2ebfd5ff5a0d5604b20b40dad32b1ff5f755e3b0b0ab26409b605c710a
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
@@ -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:CircuitBreaked if data[:status][:general] == :open and data[:raise_on_opening]
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
@@ -1,6 +1,11 @@
1
1
  module Sc4ry
2
2
  module Exceptions
3
- class CircuitBreaked < StandardError; end
3
+ class CircuitBreaked < StandardError
4
+ def initialize(msg="Circuit just opened")
5
+ super(msg)
6
+ end
7
+
8
+ end
4
9
 
5
10
  end
6
11
  end
@@ -44,9 +44,9 @@ module Sc4ry
44
44
  @failure = true
45
45
  else
46
46
  if @circuit[:forward_unknown_exceptions] then
47
- raise @last_exception.class, "Sc4ry forward: #{@last_exception.message}"
47
+ raise e.class, "Sc4ry forward: #{e.message}"
48
48
  else
49
- Sc4ry::Loggers.warning "skipped : #{@last_exception}"
49
+ Sc4ry::Helpers.log level: :debug, message: "skipped : #{@last_exception}"
50
50
  end
51
51
 
52
52
  end
data/lib/sc4ry/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Sc4ry
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.6"
3
3
  end
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.3
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-02 00:00:00.000000000 Z
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