breakers 0.5.0 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/codeql.yml +46 -0
- data/CONTRIBUTING.md +88 -0
- data/breakers.gemspec +4 -4
- data/lib/breakers/outage.rb +3 -3
- data/lib/breakers/service.rb +8 -8
- data/lib/breakers/version.rb +1 -1
- metadata +15 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d07e3fb5d5ea487bfd3a050d06ec8e5094efcb604e18554be68f849cdb0bf5a7
|
4
|
+
data.tar.gz: 4754bcc47f248d9f099dde4a9aaf494bfe47a6e9060ee592c84693e5eaceee2c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ff3ede40289743dc8f709dbcba90797b93d48b9e4ccf6215b61b0d45eb0dcb8bc04f7214d4cc8c3a53aa1e43f2318461729e24e1aebcd9490c0b137a3260ee8
|
7
|
+
data.tar.gz: bc44523288871ac14ca612e46fe4bfe167219714bae37dcb7d2fc3c97fa9f894a669fffa70b5c4060629411309bc1ab16d089d1e4b9d03491e2ec7f2dde032fd
|
@@ -0,0 +1,46 @@
|
|
1
|
+
name: "CodeQL"
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [ master ]
|
6
|
+
pull_request:
|
7
|
+
# The branches below must be a subset of the branches above
|
8
|
+
branches: [ master ]
|
9
|
+
schedule:
|
10
|
+
- cron: '27 2 * * 1'
|
11
|
+
|
12
|
+
jobs:
|
13
|
+
analyze:
|
14
|
+
name: Analyze
|
15
|
+
runs-on: ubuntu-latest
|
16
|
+
|
17
|
+
steps:
|
18
|
+
- name: Checkout repository
|
19
|
+
uses: actions/checkout@v2
|
20
|
+
|
21
|
+
# Initializes the CodeQL tools for scanning.
|
22
|
+
- name: Initialize CodeQL
|
23
|
+
uses: github/codeql-action/init@v1
|
24
|
+
# If you wish to specify custom queries, you can do so here or in a config file.
|
25
|
+
# By default, queries listed here will override any specified in a config file.
|
26
|
+
# Prefix the list here with "+" to use these queries and those in the config file.
|
27
|
+
# queries: ./path/to/local/query, your-org/your-repo/queries@main
|
28
|
+
|
29
|
+
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
30
|
+
# If this step fails, then you should remove it and run the build manually (see below)
|
31
|
+
- name: Autobuild
|
32
|
+
uses: github/codeql-action/autobuild@v1
|
33
|
+
|
34
|
+
# ℹ️ Command-line programs to run using the OS shell.
|
35
|
+
# 📚 https://git.io/JvXDl
|
36
|
+
|
37
|
+
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
|
38
|
+
# and modify them (or add more) to build your code if your project
|
39
|
+
# uses a compiled language
|
40
|
+
|
41
|
+
#- run: |
|
42
|
+
# make bootstrap
|
43
|
+
# make release
|
44
|
+
|
45
|
+
- name: Perform CodeQL Analysis
|
46
|
+
uses: github/codeql-action/analyze@v1
|
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
<!-- markdownlint-disable MD013 -->
|
2
|
+
<!-- omit in toc -->
|
3
|
+
# Contributing to breakers
|
4
|
+
|
5
|
+
First off, thanks for taking the time to contribute! :heart:
|
6
|
+
|
7
|
+
All types of contributions are encouraged and valued. See the [Table of Contents](#table-of-contents) for different ways to help and details about how this project handles them. Please make sure to read the relevant section before making your contribution. It will make it a lot easier for us project owners and smooth out the experience for all involved. The team looks forward to your contributions. :tada:
|
8
|
+
|
9
|
+
<!-- omit in toc -->
|
10
|
+
## Table of Contents
|
11
|
+
|
12
|
+
- [I Have a Question](#i-have-a-question)
|
13
|
+
- [I Want To Contribute](#i-want-to-contribute)
|
14
|
+
- [Reporting Bugs](#reporting-bugs)
|
15
|
+
- [Suggesting Enhancements](#suggesting-enhancements)
|
16
|
+
|
17
|
+
## I Have a Question
|
18
|
+
|
19
|
+
Before you ask a question, it is best to search for existing [Issues](https://github.com/department-of-veterans-affairs/issues) that might help you. In case you have found a suitable issue and still need clarification, you can write your question in this issue.
|
20
|
+
|
21
|
+
If you then still feel the need to ask a question and need clarification, we recommend the following:
|
22
|
+
|
23
|
+
- Open an [Issue](https://github.com/department-of-veterans-affairs/breakers/issues/new).
|
24
|
+
- Provide as much context as you can about what you're running into.
|
25
|
+
- Provide project and platform versions (nodejs, npm, etc), depending on what seems relevant.
|
26
|
+
|
27
|
+
We will then take care of the issue as soon as possible.
|
28
|
+
|
29
|
+
## I Want To Contribute
|
30
|
+
|
31
|
+
> ### Legal Notice <!-- omit in toc -->
|
32
|
+
> When contributing to this project, you must agree that you have authored 100% of the content, that you have the necessary rights to the content and that the content you contribute may be provided under the project license.
|
33
|
+
|
34
|
+
## Reporting Bugs
|
35
|
+
|
36
|
+
<!-- omit in toc -->
|
37
|
+
### Before Submitting a Bug Report
|
38
|
+
|
39
|
+
A good bug report shouldn't leave others needing to chase you up for more information. Therefore, we ask you to investigate carefully, collect information and describe the issue in detail in your report. Please complete the following steps in advance to help us fix any potential bug as fast as possible.
|
40
|
+
|
41
|
+
- Make sure that you are using the latest version.
|
42
|
+
- Determine if your bug is really a bug and not an error on your side e.g. using incompatible environment components/versions (Make sure that you have read the documentation. If you are looking for support, you might want to check [this section](#i-have-a-question)).
|
43
|
+
- To see if other users have experienced (and potentially already solved) the same issue you are having, check if there is not already a bug report existing for your bug or error in the [bug tracker](https://github.com/department-of-veterans-affairs/breakers/issues).
|
44
|
+
- Collect information about the bug:
|
45
|
+
- Stack trace (Traceback)
|
46
|
+
- OS, Platform and Version (Windows, Linux, macOS, x86, ARM)
|
47
|
+
- Version of the interpreter, compiler, SDK, runtime environment, package manager, depending on what seems relevant.
|
48
|
+
- Possibly your input and the output
|
49
|
+
- Can you reliably reproduce the issue? And can you also reproduce it with older versions?
|
50
|
+
|
51
|
+
<!-- omit in toc -->
|
52
|
+
### How Do I Submit a Good Bug Report?
|
53
|
+
|
54
|
+
We use GitHub issues to track bugs and errors. If you run into an issue with the project:
|
55
|
+
|
56
|
+
- Open an [Issue](https://github.com/department-of-veterans-affairs/breakers/issues/new). (Since we can't be sure at this point whether it is a bug or not, we ask you not to talk about a bug yet and not to label the issue.)
|
57
|
+
- Explain the behavior you would expect and the actual behavior.
|
58
|
+
- Please provide as much context as possible and describe the *reproduction steps* that someone else can follow to recreate the issue on their own. This usually includes your code. For good bug reports you should isolate the problem and create a reduced test case.
|
59
|
+
- Provide the information you collected in the previous section.
|
60
|
+
|
61
|
+
Once it's filed:
|
62
|
+
|
63
|
+
- The project team will label the issue accordingly.
|
64
|
+
- A team member will try to reproduce the issue with your provided steps. If there are no reproduction steps or no obvious way to reproduce the issue, the team will ask you for those steps and mark the issue as `needs-repro`. Bugs with the `needs-repro` tag will not be addressed until they are reproduced.
|
65
|
+
- If the team is able to reproduce the issue, it will be marked `needs-fix`, as well as possibly other tags (such as `critical`), and the issue will be left to be implemented by someone.
|
66
|
+
|
67
|
+
## Suggesting Enhancements
|
68
|
+
|
69
|
+
This section guides you through submitting an enhancement suggestion for breakers, **including completely new features and minor improvements to existing functionality**. Following these guidelines will help maintainers and the community to understand your suggestion and find related suggestions.
|
70
|
+
|
71
|
+
<!-- omit in toc -->
|
72
|
+
### Before Submitting an Enhancement
|
73
|
+
|
74
|
+
- Make sure that you are using the latest version.
|
75
|
+
- Read the documentation carefully and find out if the functionality is already covered, maybe by an individual configuration.
|
76
|
+
- Perform a [search](https://github.com/department-of-veterans-affairs/breakers/issues) to see if the enhancement has already been suggested. If it has, add a comment to the existing issue instead of opening a new one.
|
77
|
+
- Find out whether your idea fits with the scope and aims of the project. It's up to you to make a strong case to convince the project's developers of the merits of this feature or to develop the feature yourself and contribute it to the project.
|
78
|
+
|
79
|
+
<!-- omit in toc -->
|
80
|
+
### How Do I Submit a Good Enhancement Suggestion?
|
81
|
+
|
82
|
+
Enhancement suggestions are tracked as [GitHub issues](https://github.com/department-of-veterans-affairs/breakers/issues).
|
83
|
+
|
84
|
+
- Use a **clear and descriptive title** for the issue to identify the suggestion.
|
85
|
+
- Provide a **step-by-step description of the suggested enhancement** in as many details as possible.
|
86
|
+
- **Describe the current behavior** and **explain which behavior you expected to see instead** and why. At this point you can also tell which alternatives do not work for you.
|
87
|
+
- You may want to **include screenshots and animated GIFs** which help you demonstrate the steps or point out the part which the suggestion is related to.
|
88
|
+
- **Explain why this enhancement would be useful** to most breakers users.
|
data/breakers.gemspec
CHANGED
@@ -22,16 +22,16 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
23
|
spec.require_paths = ['lib']
|
24
24
|
|
25
|
-
spec.add_dependency 'faraday', ['>=
|
25
|
+
spec.add_dependency 'faraday', ['>= 1.2.0', '< 3.0']
|
26
26
|
spec.add_dependency 'multi_json', '~> 1.0'
|
27
27
|
|
28
|
-
spec.add_development_dependency 'bundler', '~>
|
28
|
+
spec.add_development_dependency 'bundler', '~> 2.0'
|
29
29
|
spec.add_development_dependency 'byebug', '~> 9.0'
|
30
30
|
spec.add_development_dependency 'fakeredis', '~> 0.6.0'
|
31
|
-
spec.add_development_dependency 'rake', '~>
|
31
|
+
spec.add_development_dependency 'rake', '~> 12.0'
|
32
32
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
33
33
|
spec.add_development_dependency 'rubocop', '0.43.0'
|
34
|
-
spec.add_development_dependency 'simplecov', '~> 0.12
|
34
|
+
spec.add_development_dependency 'simplecov', '~> 0.12'
|
35
35
|
spec.add_development_dependency 'timecop', '~> 0.8.0'
|
36
36
|
spec.add_development_dependency 'webmock', '~> 2.1'
|
37
37
|
end
|
data/lib/breakers/outage.rb
CHANGED
@@ -132,9 +132,9 @@ module Breakers
|
|
132
132
|
end
|
133
133
|
|
134
134
|
def replace_body(body:)
|
135
|
-
Breakers.client.redis_connection.multi do
|
136
|
-
|
137
|
-
|
135
|
+
Breakers.client.redis_connection.multi do |pipeline|
|
136
|
+
pipeline.zrem(key, MultiJson.dump(@body))
|
137
|
+
pipeline.zadd(key, start_time.to_i, MultiJson.dump(body))
|
138
138
|
end
|
139
139
|
@body = body
|
140
140
|
end
|
data/lib/breakers/service.rb
CHANGED
@@ -143,9 +143,9 @@ module Breakers
|
|
143
143
|
end
|
144
144
|
|
145
145
|
def increment_key(key:)
|
146
|
-
Breakers.client.redis_connection.multi do
|
147
|
-
|
148
|
-
|
146
|
+
Breakers.client.redis_connection.multi do |pipeline|
|
147
|
+
pipeline.incr(key)
|
148
|
+
pipeline.expire(key, @configuration[:data_retention_seconds])
|
149
149
|
end
|
150
150
|
end
|
151
151
|
|
@@ -156,11 +156,11 @@ module Breakers
|
|
156
156
|
end
|
157
157
|
|
158
158
|
def maybe_create_outage
|
159
|
-
data = Breakers.client.redis_connection.multi do
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
159
|
+
data = Breakers.client.redis_connection.multi do |pipeline|
|
160
|
+
pipeline.get(errors_key(time: Time.now.utc))
|
161
|
+
pipeline.get(errors_key(time: Time.now.utc - 60))
|
162
|
+
pipeline.get(successes_key(time: Time.now.utc))
|
163
|
+
pipeline.get(successes_key(time: Time.now.utc - 60))
|
164
164
|
end
|
165
165
|
failure_count = data[0].to_i + data[1].to_i
|
166
166
|
success_count = data[2].to_i + data[3].to_i
|
data/lib/breakers/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: breakers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aubrey Holland
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-12-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -16,20 +16,20 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 1.2.0
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '
|
22
|
+
version: '3.0'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
27
|
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version:
|
29
|
+
version: 1.2.0
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '
|
32
|
+
version: '3.0'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: multi_json
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -50,14 +50,14 @@ dependencies:
|
|
50
50
|
requirements:
|
51
51
|
- - "~>"
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: '
|
53
|
+
version: '2.0'
|
54
54
|
type: :development
|
55
55
|
prerelease: false
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
57
|
requirements:
|
58
58
|
- - "~>"
|
59
59
|
- !ruby/object:Gem::Version
|
60
|
-
version: '
|
60
|
+
version: '2.0'
|
61
61
|
- !ruby/object:Gem::Dependency
|
62
62
|
name: byebug
|
63
63
|
requirement: !ruby/object:Gem::Requirement
|
@@ -92,14 +92,14 @@ dependencies:
|
|
92
92
|
requirements:
|
93
93
|
- - "~>"
|
94
94
|
- !ruby/object:Gem::Version
|
95
|
-
version: '
|
95
|
+
version: '12.0'
|
96
96
|
type: :development
|
97
97
|
prerelease: false
|
98
98
|
version_requirements: !ruby/object:Gem::Requirement
|
99
99
|
requirements:
|
100
100
|
- - "~>"
|
101
101
|
- !ruby/object:Gem::Version
|
102
|
-
version: '
|
102
|
+
version: '12.0'
|
103
103
|
- !ruby/object:Gem::Dependency
|
104
104
|
name: rspec
|
105
105
|
requirement: !ruby/object:Gem::Requirement
|
@@ -134,14 +134,14 @@ dependencies:
|
|
134
134
|
requirements:
|
135
135
|
- - "~>"
|
136
136
|
- !ruby/object:Gem::Version
|
137
|
-
version: 0.12
|
137
|
+
version: '0.12'
|
138
138
|
type: :development
|
139
139
|
prerelease: false
|
140
140
|
version_requirements: !ruby/object:Gem::Requirement
|
141
141
|
requirements:
|
142
142
|
- - "~>"
|
143
143
|
- !ruby/object:Gem::Version
|
144
|
-
version: 0.12
|
144
|
+
version: '0.12'
|
145
145
|
- !ruby/object:Gem::Dependency
|
146
146
|
name: timecop
|
147
147
|
requirement: !ruby/object:Gem::Requirement
|
@@ -178,10 +178,12 @@ executables: []
|
|
178
178
|
extensions: []
|
179
179
|
extra_rdoc_files: []
|
180
180
|
files:
|
181
|
+
- ".github/workflows/codeql.yml"
|
181
182
|
- ".gitignore"
|
182
183
|
- ".rspec"
|
183
184
|
- ".rubocop.yml"
|
184
185
|
- ".travis.yml"
|
186
|
+
- CONTRIBUTING.md
|
185
187
|
- Gemfile
|
186
188
|
- LICENSE.md
|
187
189
|
- README.md
|
@@ -215,7 +217,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
215
217
|
- !ruby/object:Gem::Version
|
216
218
|
version: '0'
|
217
219
|
requirements: []
|
218
|
-
rubygems_version: 3.
|
220
|
+
rubygems_version: 3.4.21
|
219
221
|
signing_key:
|
220
222
|
specification_version: 4
|
221
223
|
summary: Handle outages to backend systems with a Faraday middleware
|