resilient 0.5.0 → 0.5.1

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
- SHA1:
3
- metadata.gz: a7441e56169aaa25eeeb4e40a73901f939e3af2d
4
- data.tar.gz: 04f4f827c3fc3de69439b40590ab1c3615e43376
2
+ SHA256:
3
+ metadata.gz: 2e439a74385ae133b7d375d90c75dcc302a1cd77a56d69facda7b04f2de07124
4
+ data.tar.gz: bceca2780a2b2b71ff1b0084db9e2c6ed206345114d2849d1da1c957e1995365
5
5
  SHA512:
6
- metadata.gz: e54a1abc95f5ba114b2eb4064a2d8f0190014268c7061a6869bc7811278f075331ec13cfa5758738be1690e427cfc38ca768d5f34f2258007eece41b9fc707e6
7
- data.tar.gz: bf752309fd26f431ae9c04b7dffeb68827bb05835afee1b2beed0548ecbd70333ce53c7983e2855bb2c5ae2bcdfd1f1ce1b70849c03c609f67fe061e31a9cf77
6
+ metadata.gz: 8a58ea0dce1f90dc61f4a3d34d0fa6f7ad7ca64fd246776a6696ee2e7ae1f2df9447b9f1ba394a914503320b40a1d3a2b326fd27e0e954e826fb985209233330
7
+ data.tar.gz: '088e66a7f364869da5da43f926dead2cd62af861baaa07b3a4615e521ac1ab75ecdeb4e6c7aee0b1f40ce2a692e66cca25cd2737bfe2c3fdc1635142fb96fb3a'
@@ -0,0 +1,28 @@
1
+ name: CI
2
+ on: [push, pull_request]
3
+ jobs:
4
+ build:
5
+ runs-on: ubuntu-latest
6
+ strategy:
7
+ matrix:
8
+ ruby: ['2.5', '2.6', '2.7']
9
+ steps:
10
+ - name: Check out repository code
11
+ uses: actions/checkout@v2
12
+ - name: Do some action caching
13
+ uses: actions/cache@v1
14
+ with:
15
+ path: vendor/bundle
16
+ key: ${{ runner.os }}-gem-${{ hashFiles('**/Gemfile.lock') }}
17
+ restore-keys: |
18
+ ${{ runner.os }}-gem-
19
+ - name: Set up Ruby
20
+ uses: actions/setup-ruby@v1
21
+ with:
22
+ ruby-version: ${{ matrix.ruby }}
23
+ - name: Install bundler
24
+ run: gem install bundler
25
+ - name: Run bundler
26
+ run: bundle install --jobs 4 --retry 3
27
+ - name: Run Tests
28
+ run: script/test
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.5.1
2
+
3
+ * [Added two new events open_circuit and close_circuit](https://github.com/jnunemaker/resilient/pull/16) and [renamed them here](https://github.com/jnunemaker/resilient/commit/407e673eb5268912814398bebdeb173793d0af05).
4
+
1
5
  ## 0.5.0
2
6
 
3
7
  * [tweaked interface for metrics](https://github.com/jnunemaker/resilient/pull/15)
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Some tools to aid in resiliency in Ruby. For now, just a circuit breaker (~~stolen from~~ based on [hystrix](https://github.com/netflix/hystrix)). Soon much more...
4
4
 
5
- Nothing asynchronous or thread safe yet either, but open to it and would like to see more around it in the future.
5
+ Nothing asynchronous or thread safe yet either, but open to it and would like to see more around it in the future. See more here: [jnunemaker/resilient#18](https://github.com/jnunemaker/resilient/issues/18).
6
6
 
7
7
  ## Installation
8
8
 
@@ -29,7 +29,7 @@ require "resilient/circuit_breaker"
29
29
  # CircuitBreaker.new as `get` keeps a registry of circuits by key to prevent
30
30
  # creating multiple instances of the same circuit breaker for a key; not using
31
31
  # `get` means you would have multiple instances of the circuit breaker and thus
32
- # separate state and metrics; you can read more in examples/for_vs_new.rb
32
+ # separate state and metrics; you can read more in examples/get_vs_new.rb
33
33
  circuit_breaker = Resilient::CircuitBreaker.get("example")
34
34
  if circuit_breaker.allow_request?
35
35
  begin
@@ -86,15 +86,15 @@ circuit_breaker = Resilient::CircuitBreaker.get("example", {
86
86
 
87
87
  Property | Default | Notes
88
88
  --------------------------------|------------------------|--------
89
- **:force_open** | false | allows forcing the circuit open (stopping all requests)
90
- **:force_closed** | false | allows ignoring errors and therefore never trip "open" (ie. allow all traffic through); normal instrumentation will still happen, thus allowing you to "test" configuration live without impact
91
- **:instrumenter** | Instrumenters::Noop | what to use to instrument all events that happen (ie: ActiveSupport::Notifications)
92
- **:sleep_window_seconds** | 5 | seconds after tripping circuit before allowing retry
93
- **:request_volume_threshold** | 20 | number of requests that must be made within a statistical window before open/close decisions are made using stats
94
- **:error_threshold_percentage** | 50 | % of "marks" that must be failed to trip the circuit
95
- **:window_size_in_seconds** | 60 | number of seconds in the statistical window
96
- **:bucket_size_in_seconds** | 10 | size of buckets in statistical window
97
- **:metrics** | Resilient::Metrics.new | metrics instance used to keep track of success and failure
89
+ **:force_open** | `false` | allows forcing the circuit open (stopping all requests)
90
+ **:force_closed** | `false` | allows ignoring errors and therefore never trip "open" (e.g. allow all traffic through); normal instrumentation will still happen, thus allowing you to "test" configuration live without impact
91
+ **:instrumenter** | `Instrumenters::Noop` | what to use to instrument all events that happen (e.g. `ActiveSupport::Notifications`)
92
+ **:sleep_window_seconds** | `5` | seconds after tripping circuit before allowing retry
93
+ **:request_volume_threshold** | `20` | number of requests that must be made within a statistical window before open/close decisions are made using stats
94
+ **:error_threshold_percentage** | `50` | % of "marks" that must be failed to trip the circuit
95
+ **:window_size_in_seconds** | `60` | number of seconds in the statistical window
96
+ **:bucket_size_in_seconds** | `10` | size of buckets in statistical window
97
+ **:metrics** | `Resilient::Metrics.new` | metrics instance used to keep track of success and failure
98
98
 
99
99
  ## Tests
100
100
 
@@ -106,13 +106,20 @@ module Resilient
106
106
  private
107
107
 
108
108
  def open_circuit
109
- @opened_or_last_checked_at_epoch = Time.now.to_i
110
- @open = true
109
+ instrument("resilient.circuit_breaker.open_circuit", key: @key) { |payload|
110
+ @opened_or_last_checked_at_epoch = Time.now.to_i
111
+ @open = true
112
+ payload[:open] = @open
113
+ }
111
114
  end
112
115
 
113
116
  def close_circuit
114
- @open = false
115
- @opened_or_last_checked_at_epoch = 0
117
+ instrument("resilient.circuit_breaker.close_circuit", key: @key) { |payload|
118
+ @open = false
119
+ payload[:open] = @open
120
+ payload[:interval] = Time.now.to_i - @opened_or_last_checked_at_epoch
121
+ @opened_or_last_checked_at_epoch = 0
122
+ }
116
123
  metrics.reset
117
124
  end
118
125
 
@@ -1,3 +1,3 @@
1
1
  module Resilient
2
- VERSION = "0.5.0"
2
+ VERSION = "0.5.1"
3
3
  end
data/resilient.gemspec CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
18
18
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_development_dependency "bundler", "~> 1.10"
21
+ spec.add_development_dependency "bundler", "< 3.0"
22
22
  spec.add_development_dependency "minitest", "~> 5.8"
23
23
  spec.add_development_dependency "timecop", "~> 0.8.0"
24
24
  end
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: resilient
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Nunemaker
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-07-05 00:00:00.000000000 Z
11
+ date: 2021-04-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - "<"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.10'
19
+ version: '3.0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - "<"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.10'
26
+ version: '3.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: minitest
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -59,8 +59,8 @@ executables: []
59
59
  extensions: []
60
60
  extra_rdoc_files: []
61
61
  files:
62
+ - ".github/workflows/ci.yml"
62
63
  - ".gitignore"
63
- - ".travis.yml"
64
64
  - CHANGELOG.md
65
65
  - Gemfile
66
66
  - Guardfile
@@ -114,8 +114,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
114
114
  - !ruby/object:Gem::Version
115
115
  version: '0'
116
116
  requirements: []
117
- rubyforge_project:
118
- rubygems_version: 2.4.5.1
117
+ rubygems_version: 3.0.3
119
118
  signing_key:
120
119
  specification_version: 4
121
120
  summary: toolkit for resilient ruby apps
data/.travis.yml DELETED
@@ -1,8 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.0.0
4
- - 2.1.4
5
- - 2.2.3
6
- before_install: gem install bundler -v 1.10.6
7
- bundler_args: --without=development
8
- script: script/test