rack-ecg 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +2 -0
- data/.github/workflows/test.yml +2 -3
- data/.rubocop.yml +2 -0
- data/.ruby-version +1 -1
- data/CHANGELOG.md +13 -1
- data/README.md +14 -2
- data/Rakefile +5 -1
- data/examples/custom_failure_status.ru +11 -0
- data/examples/git_revision_check_replacement.ru +1 -1
- data/lib/rack/ecg/check/error.rb +1 -1
- data/lib/rack/ecg/check/http.rb +1 -1
- data/lib/rack/ecg/check/redis_connection.rb +4 -5
- data/lib/rack/ecg/check_registry.rb +9 -7
- data/lib/rack/ecg/version.rb +1 -1
- data/lib/rack/ecg.rb +10 -4
- data/rack-ecg.gemspec +8 -10
- metadata +25 -52
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d9102753e910fc1dc1008ff19d2a1d3bd23db4fdb6f0ac24f322d0750294b429
|
4
|
+
data.tar.gz: 189b4f010c85128da3d317b813ab829023b2db2793e1df4ce01bfbd9d6b67bfb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6c7698889a12a7c2263b4f70c366423691d5d4a3cd7f9d74bbb94a3e974087143f2c9906bc9cdf0e234d3dc2ece5ea840458b0f60d2f94cb250288b1a86f6073
|
7
|
+
data.tar.gz: 96fc9feb30b537fccf7cd377716078c9bfd6a9c33f33f1ac9d9cf1375863e6b751f48ea2670ee7c1d4b03b9ddf4be9f4d1e63be258fe7936b70824bf59b16c0b
|
data/.github/dependabot.yml
CHANGED
data/.github/workflows/test.yml
CHANGED
@@ -6,17 +6,16 @@ jobs:
|
|
6
6
|
test:
|
7
7
|
strategy:
|
8
8
|
matrix:
|
9
|
-
ruby: ["2.
|
9
|
+
ruby: ["2.7", "3.0", "3.1", "3.2"]
|
10
10
|
runs-on: ubuntu-latest
|
11
11
|
name: Test (Ruby ${{ matrix.ruby }})
|
12
12
|
steps:
|
13
|
-
- uses: actions/checkout@
|
13
|
+
- uses: actions/checkout@v3
|
14
14
|
- name: Set up Ruby
|
15
15
|
uses: ruby/setup-ruby@v1
|
16
16
|
with:
|
17
17
|
ruby-version: ${{ matrix.ruby }}
|
18
18
|
- name: Run the default task
|
19
19
|
run: |
|
20
|
-
gem install bundler -v 2.3.7
|
21
20
|
bundle install
|
22
21
|
bundle exec rake
|
data/.rubocop.yml
CHANGED
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
3.2.2
|
data/CHANGELOG.md
CHANGED
@@ -1,10 +1,21 @@
|
|
1
1
|
# Changelog
|
2
|
+
|
2
3
|
All notable changes to this project will be documented in this file.
|
3
4
|
|
4
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
5
6
|
|
6
7
|
## [Unreleased]
|
7
8
|
|
9
|
+
## [0.3.0] - 2023-09-08
|
10
|
+
|
11
|
+
### Added
|
12
|
+
|
13
|
+
- (#53) Add a configuration option for the unhealthy status code - thanks @floere!
|
14
|
+
|
15
|
+
### Removed
|
16
|
+
|
17
|
+
- **Breaking:** Dropped support for Ruby versions < 2.7.0
|
18
|
+
|
8
19
|
## [0.2.0] - 2022-02-21
|
9
20
|
|
10
21
|
### Added
|
@@ -74,7 +85,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
74
85
|
- `git_revision` check to return the current git revision
|
75
86
|
- `migration_version` check to return the current ActiveRecord migration version
|
76
87
|
|
77
|
-
[Unreleased]: https://github.com/envato/rack-ecg/compare/v0.
|
88
|
+
[Unreleased]: https://github.com/envato/rack-ecg/compare/v0.3.0...HEAD
|
89
|
+
[0.3.0]: https://github.com/envato/rack-ecg/compare/v0.2.0...v0.3.0
|
78
90
|
[0.2.0]: https://github.com/envato/rack-ecg/compare/v0.1.0...v0.2.0
|
79
91
|
[0.1.0]: https://github.com/envato/rack-ecg/compare/v0.0.5...v0.1.0
|
80
92
|
[0.0.5]: https://github.com/envato/rack-ecg/compare/v0.0.4...v0.0.5
|
data/README.md
CHANGED
@@ -28,7 +28,7 @@ APIs and features are almost certain to be in flux.
|
|
28
28
|
Add this to your application's `Gemfile`:
|
29
29
|
|
30
30
|
```ruby
|
31
|
-
gem 'rack-ecg', '~> 0.
|
31
|
+
gem 'rack-ecg', '~> 0.3.0`
|
32
32
|
```
|
33
33
|
|
34
34
|
Then run `bundle install`.
|
@@ -241,7 +241,14 @@ use Rack::ECG, hook: Proc.new { |success, _checks| puts "Is healthy? #{success}"
|
|
241
241
|
- `success`: whether the response will indicate success
|
242
242
|
- `checks`: an array of the check names and values
|
243
243
|
|
244
|
-
|
244
|
+
### `failure_status`
|
245
|
+
|
246
|
+
By default, check failures result in a HTTP status code `500` (Internal Server
|
247
|
+
Error). You can change this code by setting the `failure_status` option. e.g.
|
248
|
+
|
249
|
+
```ruby
|
250
|
+
use Rack::ECG, checks: [:error], failure_status: 503
|
251
|
+
```
|
245
252
|
|
246
253
|
## Requirements
|
247
254
|
|
@@ -252,6 +259,10 @@ More examples are provided in [/examples](https://github.com/envato/rack-ecg/tre
|
|
252
259
|
- To use optional `migration_version` check, you must be using ActiveRecord and
|
253
260
|
migrations stored in `schema_versions` table
|
254
261
|
|
262
|
+
## Examples
|
263
|
+
|
264
|
+
Some configuration examples are provided in [/examples](https://github.com/envato/rack-ecg/tree/main/examples).
|
265
|
+
|
255
266
|
## Contact
|
256
267
|
|
257
268
|
- [github project](https://github.com/envato/rack-ecg)
|
@@ -262,6 +273,7 @@ migrations stored in `schema_versions` table
|
|
262
273
|
## Maintainers
|
263
274
|
|
264
275
|
- [Liam Dawson](https://github.com/liamdawson)
|
276
|
+
- [Andrew Davis](https://github.com/andyjdavis)
|
265
277
|
|
266
278
|
## Contributors
|
267
279
|
|
data/Rakefile
CHANGED
data/lib/rack/ecg/check/error.rb
CHANGED
data/lib/rack/ecg/check/http.rb
CHANGED
@@ -3,14 +3,13 @@
|
|
3
3
|
module Rack
|
4
4
|
class ECG
|
5
5
|
module Check
|
6
|
-
# @!method initialize
|
7
|
-
# Checks whether the given Redis client is currently connected to the
|
8
|
-
# database as identified by the ++instance++ option.
|
9
|
-
#
|
10
|
-
# @option parameters instance [Redis] The Redis client
|
11
6
|
class RedisConnection
|
12
7
|
attr_reader :redis_instance
|
13
8
|
|
9
|
+
# Checks whether the given Redis client is currently connected to the
|
10
|
+
# database as identified by the ++instance++ option.
|
11
|
+
#
|
12
|
+
# @option parameters instance [Redis] The Redis client
|
14
13
|
def initialize(parameters = {})
|
15
14
|
@redis_instance = parameters[:instance]
|
16
15
|
end
|
@@ -30,14 +30,16 @@ module Rack
|
|
30
30
|
@registry.fetch(name) { raise CheckNotRegistered, "Check '#{name}' is not registered" }
|
31
31
|
end
|
32
32
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
33
|
+
class << self
|
34
|
+
# (see #lookup)
|
35
|
+
def lookup(name)
|
36
|
+
instance.lookup(name)
|
37
|
+
end
|
37
38
|
|
38
|
-
|
39
|
-
|
40
|
-
|
39
|
+
# (see #register)
|
40
|
+
def register(name, check_class)
|
41
|
+
instance.register(name, check_class)
|
42
|
+
end
|
41
43
|
end
|
42
44
|
end
|
43
45
|
end
|
data/lib/rack/ecg/version.rb
CHANGED
data/lib/rack/ecg.rb
CHANGED
@@ -11,6 +11,8 @@ module Rack
|
|
11
11
|
DEFAULT_MOUNT_AT = "/_ecg"
|
12
12
|
# Checks enabled by default.
|
13
13
|
DEFAULT_CHECKS = [:http]
|
14
|
+
# Default failure response status.
|
15
|
+
DEFAULT_FAILURE_STATUS = 500
|
14
16
|
|
15
17
|
# Constructs an instance of ECG Rack middleware with the specified
|
16
18
|
# options.
|
@@ -22,7 +24,9 @@ module Rack
|
|
22
24
|
# @param at [String, nil] Path which this ECG instance handles.
|
23
25
|
# @param hook [#call, nil] Callable which receives the success status and
|
24
26
|
# check results
|
25
|
-
|
27
|
+
# @param failure_status [Integer] Status code to return on check failure
|
28
|
+
def initialize(app = nil, checks: DEFAULT_CHECKS, at: DEFAULT_MOUNT_AT, hook: nil,
|
29
|
+
failure_status: DEFAULT_FAILURE_STATUS)
|
26
30
|
@app = app
|
27
31
|
|
28
32
|
check_configuration = checks || []
|
@@ -30,6 +34,8 @@ module Rack
|
|
30
34
|
@mount_at = at || DEFAULT_MOUNT_AT
|
31
35
|
|
32
36
|
@result_hook = hook
|
37
|
+
|
38
|
+
@failure_response_status = failure_status
|
33
39
|
end
|
34
40
|
|
35
41
|
# Rack compatible call method. Not intended for direct usage.
|
@@ -41,13 +47,13 @@ module Rack
|
|
41
47
|
|
42
48
|
success = check_results.none? { |check| check[1][:status] == Check::Status::ERROR }
|
43
49
|
|
44
|
-
response_status = success ? 200 :
|
50
|
+
response_status = success ? 200 : @failure_response_status
|
45
51
|
|
46
52
|
@result_hook&.call(success, check_results)
|
47
53
|
|
48
54
|
response_headers = {
|
49
|
-
"
|
50
|
-
"
|
55
|
+
"x-rack-ecg-version" => Rack::ECG::VERSION,
|
56
|
+
"content-type" => "application/json",
|
51
57
|
}
|
52
58
|
|
53
59
|
response_body = JSON.pretty_generate(check_results)
|
data/rack-ecg.gemspec
CHANGED
@@ -30,18 +30,16 @@ Gem::Specification.new do |spec|
|
|
30
30
|
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
31
31
|
spec.require_paths = ["lib"]
|
32
32
|
|
33
|
-
spec.required_ruby_version = Gem::Requirement.new(">= 2.
|
33
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
|
34
34
|
|
35
35
|
spec.add_runtime_dependency("rack")
|
36
36
|
|
37
|
-
spec.add_development_dependency("
|
38
|
-
spec.add_development_dependency("
|
39
|
-
spec.add_development_dependency("
|
37
|
+
spec.add_development_dependency("pry", "~> 0.14.2")
|
38
|
+
spec.add_development_dependency("rack-test", "~> 2.1.0")
|
39
|
+
spec.add_development_dependency("rackup", "~> 2.1.0")
|
40
40
|
spec.add_development_dependency("rake", "~> 13.0")
|
41
|
-
spec.add_development_dependency("redcarpet", "~> 3.
|
42
|
-
spec.add_development_dependency("rspec", "~> 3.
|
43
|
-
spec.add_development_dependency("rubocop-
|
44
|
-
spec.add_development_dependency("
|
45
|
-
spec.add_development_dependency("rubocop-shopify", "~> 2.4.0")
|
46
|
-
spec.add_development_dependency("yard", "~> 0.9.24")
|
41
|
+
spec.add_development_dependency("redcarpet", "~> 3.6.0")
|
42
|
+
spec.add_development_dependency("rspec", "~> 3.12.0")
|
43
|
+
spec.add_development_dependency("rubocop-shopify", "~> 2.14")
|
44
|
+
spec.add_development_dependency("yard", "~> 0.9.34")
|
47
45
|
end
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-ecg
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Envato
|
8
8
|
- Julian Doherty
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2023-09-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rack
|
@@ -26,47 +26,47 @@ dependencies:
|
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: '0'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
|
-
name:
|
29
|
+
name: pry
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
32
|
- - "~>"
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version:
|
34
|
+
version: 0.14.2
|
35
35
|
type: :development
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
39
|
- - "~>"
|
40
40
|
- !ruby/object:Gem::Version
|
41
|
-
version:
|
41
|
+
version: 0.14.2
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
|
-
name:
|
43
|
+
name: rack-test
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
46
|
- - "~>"
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version:
|
48
|
+
version: 2.1.0
|
49
49
|
type: :development
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
53
|
- - "~>"
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version:
|
55
|
+
version: 2.1.0
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
|
-
name:
|
57
|
+
name: rackup
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
59
59
|
requirements:
|
60
60
|
- - "~>"
|
61
61
|
- !ruby/object:Gem::Version
|
62
|
-
version:
|
62
|
+
version: 2.1.0
|
63
63
|
type: :development
|
64
64
|
prerelease: false
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
66
66
|
requirements:
|
67
67
|
- - "~>"
|
68
68
|
- !ruby/object:Gem::Version
|
69
|
-
version:
|
69
|
+
version: 2.1.0
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
71
|
name: rake
|
72
72
|
requirement: !ruby/object:Gem::Requirement
|
@@ -87,84 +87,56 @@ dependencies:
|
|
87
87
|
requirements:
|
88
88
|
- - "~>"
|
89
89
|
- !ruby/object:Gem::Version
|
90
|
-
version: 3.
|
90
|
+
version: 3.6.0
|
91
91
|
type: :development
|
92
92
|
prerelease: false
|
93
93
|
version_requirements: !ruby/object:Gem::Requirement
|
94
94
|
requirements:
|
95
95
|
- - "~>"
|
96
96
|
- !ruby/object:Gem::Version
|
97
|
-
version: 3.
|
97
|
+
version: 3.6.0
|
98
98
|
- !ruby/object:Gem::Dependency
|
99
99
|
name: rspec
|
100
100
|
requirement: !ruby/object:Gem::Requirement
|
101
101
|
requirements:
|
102
102
|
- - "~>"
|
103
103
|
- !ruby/object:Gem::Version
|
104
|
-
version: 3.
|
104
|
+
version: 3.12.0
|
105
105
|
type: :development
|
106
106
|
prerelease: false
|
107
107
|
version_requirements: !ruby/object:Gem::Requirement
|
108
108
|
requirements:
|
109
109
|
- - "~>"
|
110
110
|
- !ruby/object:Gem::Version
|
111
|
-
version: 3.
|
112
|
-
- !ruby/object:Gem::Dependency
|
113
|
-
name: rubocop-rake
|
114
|
-
requirement: !ruby/object:Gem::Requirement
|
115
|
-
requirements:
|
116
|
-
- - ">"
|
117
|
-
- !ruby/object:Gem::Version
|
118
|
-
version: '0'
|
119
|
-
type: :development
|
120
|
-
prerelease: false
|
121
|
-
version_requirements: !ruby/object:Gem::Requirement
|
122
|
-
requirements:
|
123
|
-
- - ">"
|
124
|
-
- !ruby/object:Gem::Version
|
125
|
-
version: '0'
|
126
|
-
- !ruby/object:Gem::Dependency
|
127
|
-
name: rubocop-rspec
|
128
|
-
requirement: !ruby/object:Gem::Requirement
|
129
|
-
requirements:
|
130
|
-
- - ">"
|
131
|
-
- !ruby/object:Gem::Version
|
132
|
-
version: '0'
|
133
|
-
type: :development
|
134
|
-
prerelease: false
|
135
|
-
version_requirements: !ruby/object:Gem::Requirement
|
136
|
-
requirements:
|
137
|
-
- - ">"
|
138
|
-
- !ruby/object:Gem::Version
|
139
|
-
version: '0'
|
111
|
+
version: 3.12.0
|
140
112
|
- !ruby/object:Gem::Dependency
|
141
113
|
name: rubocop-shopify
|
142
114
|
requirement: !ruby/object:Gem::Requirement
|
143
115
|
requirements:
|
144
116
|
- - "~>"
|
145
117
|
- !ruby/object:Gem::Version
|
146
|
-
version: 2.
|
118
|
+
version: '2.14'
|
147
119
|
type: :development
|
148
120
|
prerelease: false
|
149
121
|
version_requirements: !ruby/object:Gem::Requirement
|
150
122
|
requirements:
|
151
123
|
- - "~>"
|
152
124
|
- !ruby/object:Gem::Version
|
153
|
-
version: 2.
|
125
|
+
version: '2.14'
|
154
126
|
- !ruby/object:Gem::Dependency
|
155
127
|
name: yard
|
156
128
|
requirement: !ruby/object:Gem::Requirement
|
157
129
|
requirements:
|
158
130
|
- - "~>"
|
159
131
|
- !ruby/object:Gem::Version
|
160
|
-
version: 0.9.
|
132
|
+
version: 0.9.34
|
161
133
|
type: :development
|
162
134
|
prerelease: false
|
163
135
|
version_requirements: !ruby/object:Gem::Requirement
|
164
136
|
requirements:
|
165
137
|
- - "~>"
|
166
138
|
- !ruby/object:Gem::Version
|
167
|
-
version: 0.9.
|
139
|
+
version: 0.9.34
|
168
140
|
description: |2
|
169
141
|
rack-ecg allows you to serve a page that shows you facts about your deployed
|
170
142
|
app to allow you to check that everything is running as it should: git
|
@@ -193,6 +165,7 @@ files:
|
|
193
165
|
- docker-compose.yml
|
194
166
|
- examples/basic.ru
|
195
167
|
- examples/checks.ru
|
168
|
+
- examples/custom_failure_status.ru
|
196
169
|
- examples/git_revision_check_replacement.ru
|
197
170
|
- examples/hook.ru
|
198
171
|
- examples/mounted_path.ru
|
@@ -220,7 +193,7 @@ metadata:
|
|
220
193
|
homepage_uri: https://github.com/envato/rack-ecg
|
221
194
|
source_code_uri: https://github.com/envato/rack-ecg
|
222
195
|
changelog_uri: https://github.com/envato/rack-ecg/blob/main/CHANGELOG.md
|
223
|
-
post_install_message:
|
196
|
+
post_install_message:
|
224
197
|
rdoc_options: []
|
225
198
|
require_paths:
|
226
199
|
- lib
|
@@ -228,15 +201,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
228
201
|
requirements:
|
229
202
|
- - ">="
|
230
203
|
- !ruby/object:Gem::Version
|
231
|
-
version: 2.
|
204
|
+
version: 2.7.0
|
232
205
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
233
206
|
requirements:
|
234
207
|
- - ">="
|
235
208
|
- !ruby/object:Gem::Version
|
236
209
|
version: '0'
|
237
210
|
requirements: []
|
238
|
-
rubygems_version: 3.
|
239
|
-
signing_key:
|
211
|
+
rubygems_version: 3.4.10
|
212
|
+
signing_key:
|
240
213
|
specification_version: 4
|
241
214
|
summary: Rack middleware serving a health check page
|
242
215
|
test_files: []
|