sc4ry 0.1.1 → 0.1.4

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: 0cf4e754e862f6af5921390386a8138d61168ca2dcc74be2af5024d554c16d27
4
- data.tar.gz: f3b6bd16ed96d045058e2d05b7c7c24eb0e8feb9c57368301489f76d6fe1e4c5
3
+ metadata.gz: 63f7aa01b54f949abb2f4dd1443fd8b42a16346673200e9394d091dafc5efb06
4
+ data.tar.gz: fbed3c85b892cf1997100ed7753a48f51bcfff106285071083e4f6fc6845b7c3
5
5
  SHA512:
6
- metadata.gz: ed8241fdf174a9c6f6be4e61ada6627c62a246d574910bb83579fec77a0e919227bae3b2a1c00d3cfd469e5fbcab134d275fa19c7566536120901073ffee8ba0
7
- data.tar.gz: 3d20056f6e08c289307beef56473f71e1a60b115d38ff119e0177317ffb8fca6b336451c62437fd8d7eb737463234b9734b962ddf02a936e3afc692d0588c0d5
6
+ metadata.gz: 2435573c1f5e0d1476548f2d581f4a00029d6c8d67a4824402e8de3b5b3528cc32d307149e61ad1cd751fb3561a43cd75c6ae7791888c1c8048258ce2c9fcfd8
7
+ data.tar.gz: 9bd96086e6cc1260c9e1e43df45b4743d2d8c8d4df5d4ae23eb8af32822960304aa38d363626ca816895861eed79839ca0f3311995ad301904fc941aef8fc6e0
@@ -11,6 +11,8 @@ module Sc4ry
11
11
  :max_overtime_count => 3,
12
12
  :check_delay => 30,
13
13
  :notifiers => [],
14
+ :forward_unknown_exceptions => true,
15
+ :raise_on_opening => false,
14
16
  :exceptions => [StandardError, RuntimeError]
15
17
  }
16
18
 
@@ -86,7 +88,10 @@ module Sc4ry
86
88
  [:closed,:half_open,:open].each do |status|
87
89
  data[:status][:general] = status if worst_status.include? status
88
90
  end
89
- Sc4ry::Helpers.notify circuit: options[:circuit], config: data if save != data[:status][:general]
91
+ if save != data[:status][:general] then
92
+ raise Sc4ry::Exceptions::CircuitBreaked if data[:status][:general] == :open and data[:raise_on_opening]
93
+ Sc4ry::Helpers.notify circuit: options[:circuit], config: data
94
+ end
90
95
  @@circuits_store.put key: options[:circuit], value: data
91
96
  end
92
97
  end
@@ -13,7 +13,9 @@ require 'uri'
13
13
  require 'json'
14
14
 
15
15
 
16
+
16
17
  require_relative 'helpers'
18
+ require_relative 'exceptions'
17
19
  require_relative 'logger'
18
20
  require_relative 'backends/init'
19
21
  require_relative 'store'
@@ -0,0 +1,11 @@
1
+ module Sc4ry
2
+ module Exceptions
3
+ class CircuitBreaked < StandardError
4
+ def initialize(msg="Circuit just opened")
5
+ super(msg)
6
+ end
7
+
8
+ end
9
+
10
+ end
11
+ end
data/lib/sc4ry/logger.rb CHANGED
@@ -19,7 +19,7 @@ module Sc4ry
19
19
 
20
20
  def Logger.current=(sym)
21
21
  raise "Logger not define : #{sym}" unless @@loggers.keys.include? sym
22
- @@default = sym
22
+ @@current = sym
23
23
  end
24
24
 
25
25
  def Logger.register(options = {})
@@ -43,7 +43,12 @@ module Sc4ry
43
43
  elsif @circuit[:exceptions].include? e.class
44
44
  @failure = true
45
45
  else
46
- Sc4ry::Loggers.warning "skipped : #{@last_exception}"
46
+ if @circuit[:forward_unknown_exceptions] then
47
+ raise e.class, "Sc4ry forward: #{e.message}"
48
+ else
49
+ Sc4ry::Helpers.log level: :debug, message: "skipped : #{@last_exception}"
50
+ end
51
+
47
52
  end
48
53
  end
49
54
  @end_time = Process.clock_gettime(Process::CLOCK_MONOTONIC)
data/lib/sc4ry/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Sc4ry
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sc4ry
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.4
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-01 00:00:00.000000000 Z
11
+ date: 2022-03-02 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Sc4ry provide the design pattern Circuit breaker for your application.
14
14
  email:
@@ -33,6 +33,7 @@ files:
33
33
  - lib/sc4ry/backends/redis.rb
34
34
  - lib/sc4ry/circuits.rb
35
35
  - lib/sc4ry/dependencies.rb
36
+ - lib/sc4ry/exceptions.rb
36
37
  - lib/sc4ry/exporters/init.rb
37
38
  - lib/sc4ry/helpers.rb
38
39
  - lib/sc4ry/logger.rb