rx-healthcheck 0.1.9 → 0.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +4 -3
- data/Gemfile.lock +12 -8
- data/README.md +14 -1
- data/lib/rx/check/active_record_check.rb +2 -1
- data/lib/rx/middleware.rb +8 -5
- data/lib/rx/version.rb +1 -1
- metadata +3 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0a13e928ecfa7c5c8682acbe7a23dd10d4436eab15bde8b90814292f1a272505
|
|
4
|
+
data.tar.gz: 8bde613b1ff1c3dc35dae09301daaf08556219119f0d0e02e03e5e37addfb715
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f157a6e801558bb7155bba0d8654216c7c38a1a1259cd797a6d36dad1506b49b19998bb5078e4efa62ee0b48765caa1c69fe992ac37b8d0738455f623107a61f
|
|
7
|
+
data.tar.gz: 44f380e98847f3c5ffe00e7ee62b9e06ed2bfcfb5af86e510759f762e18955a33aa63de8eb19782d9f3645e49bd894f96953099babae9f0ef48385ad3f79bd3f
|
data/Gemfile
CHANGED
|
@@ -5,7 +5,8 @@ source "https://rubygems.org"
|
|
|
5
5
|
# Specify your gem's dependencies in rx.gemspec
|
|
6
6
|
gemspec
|
|
7
7
|
|
|
8
|
-
gem "rake", "~> 13.
|
|
8
|
+
gem "rake", "~> 13.3"
|
|
9
9
|
|
|
10
|
-
gem "minitest",
|
|
11
|
-
gem "
|
|
10
|
+
gem "minitest", "~> 6"
|
|
11
|
+
gem "minitest-mock", "~> 5"
|
|
12
|
+
gem "simplecov", "0.22"
|
data/Gemfile.lock
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
rx-healthcheck (0.1.
|
|
4
|
+
rx-healthcheck (0.1.10)
|
|
5
5
|
|
|
6
6
|
GEM
|
|
7
7
|
remote: https://rubygems.org/
|
|
8
8
|
specs:
|
|
9
9
|
docile (1.4.0)
|
|
10
|
-
minitest (
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
minitest (6.0.1)
|
|
11
|
+
prism (~> 1.5)
|
|
12
|
+
minitest-mock (5.27.0)
|
|
13
|
+
prism (1.9.0)
|
|
14
|
+
rake (13.3.1)
|
|
15
|
+
simplecov (0.22.0)
|
|
13
16
|
docile (~> 1.1)
|
|
14
17
|
simplecov-html (~> 0.11)
|
|
15
18
|
simplecov_json_formatter (~> 0.1)
|
|
@@ -21,10 +24,11 @@ PLATFORMS
|
|
|
21
24
|
x86_64-linux
|
|
22
25
|
|
|
23
26
|
DEPENDENCIES
|
|
24
|
-
minitest (~>
|
|
25
|
-
|
|
27
|
+
minitest (~> 6)
|
|
28
|
+
minitest-mock (~> 5)
|
|
29
|
+
rake (~> 13.3)
|
|
26
30
|
rx-healthcheck!
|
|
27
|
-
simplecov (= 0.
|
|
31
|
+
simplecov (= 0.22)
|
|
28
32
|
|
|
29
33
|
BUNDLED WITH
|
|
30
|
-
2.
|
|
34
|
+
2.6.9
|
data/README.md
CHANGED
|
@@ -20,7 +20,7 @@ Rx provides three levels of health checks:
|
|
|
20
20
|
|
|
21
21
|
### Rails Applications
|
|
22
22
|
|
|
23
|
-
Add `rx` to your Gemfile, and then create a new initializer with something like this:
|
|
23
|
+
Add `rx-healthcheck` to your Gemfile, and then create a new initializer with something like this:
|
|
24
24
|
|
|
25
25
|
```ruby
|
|
26
26
|
Rails.application.config.middleware.insert(
|
|
@@ -97,6 +97,19 @@ options: {
|
|
|
97
97
|
}
|
|
98
98
|
```
|
|
99
99
|
|
|
100
|
+
### Customizing health-check endpoints
|
|
101
|
+
|
|
102
|
+
By default, Rx will mount the health checks at `/liveness`, `/readiness`, and `/deep`. You can customize these endpoints by passing a `liveness_path`, `readiness_path`, and `deep_path` options to the middleware:
|
|
103
|
+
|
|
104
|
+
```ruby
|
|
105
|
+
# in this example, liveness and readiness endpoints have been customized. the deep
|
|
106
|
+
# endpoint will use the default path (/deep).
|
|
107
|
+
Rx::Middleware.new(options: {
|
|
108
|
+
liveness_path: "/other_liveness",
|
|
109
|
+
readiness_path: "/other_readiness"
|
|
110
|
+
})
|
|
111
|
+
```
|
|
112
|
+
|
|
100
113
|
## Contributing
|
|
101
114
|
|
|
102
115
|
Bug reports and pull requests are welcome on GitHub at https://github.com/zachpendleton/rx.
|
|
@@ -13,6 +13,7 @@ module Rx
|
|
|
13
13
|
raise StandardError.new("Undefined class ActiveRecord::Base")
|
|
14
14
|
end
|
|
15
15
|
|
|
16
|
+
ActiveRecord::Base.connection.connect! unless ActiveRecord::Base.connection.active?
|
|
16
17
|
ActiveRecord::Base.connection.active?
|
|
17
18
|
end
|
|
18
19
|
end
|
|
@@ -24,4 +25,4 @@ module Rx
|
|
|
24
25
|
end
|
|
25
26
|
end
|
|
26
27
|
end
|
|
27
|
-
end
|
|
28
|
+
end
|
data/lib/rx/middleware.rb
CHANGED
|
@@ -4,7 +4,10 @@ module Rx
|
|
|
4
4
|
class Middleware
|
|
5
5
|
DEFAULT_OPTIONS = {
|
|
6
6
|
cache: true,
|
|
7
|
-
authorization: nil
|
|
7
|
+
authorization: nil,
|
|
8
|
+
liveness_path: "/liveness",
|
|
9
|
+
readiness_path: "/readiness",
|
|
10
|
+
deep_path: "/deep"
|
|
8
11
|
}.freeze
|
|
9
12
|
|
|
10
13
|
def initialize(app,
|
|
@@ -29,12 +32,12 @@ module Rx
|
|
|
29
32
|
end
|
|
30
33
|
|
|
31
34
|
case path(env)
|
|
32
|
-
when
|
|
35
|
+
when @options[:liveness_path]
|
|
33
36
|
ok = check_to_component(liveness_checks).map { |x| x[:status] == 200 }.all?
|
|
34
37
|
liveness_response(ok)
|
|
35
|
-
when
|
|
38
|
+
when @options[:readiness_path]
|
|
36
39
|
readiness_response(check_to_component(readiness_checks))
|
|
37
|
-
when
|
|
40
|
+
when @options[:deep_path]
|
|
38
41
|
if !Rx::Util::HealthCheckAuthorization.new(env, @options[:authorization]).ok?
|
|
39
42
|
deep_response_authorization_failed
|
|
40
43
|
else
|
|
@@ -68,7 +71,7 @@ module Rx
|
|
|
68
71
|
end
|
|
69
72
|
|
|
70
73
|
def health_check_request?(path)
|
|
71
|
-
|
|
74
|
+
[@options[:liveness_path], @options[:readiness_path], @options[:deep_path]].include?(path)
|
|
72
75
|
end
|
|
73
76
|
|
|
74
77
|
def liveness_response(is_ok)
|
data/lib/rx/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rx-healthcheck
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.11
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Zach Pendleton
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: exe
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies: []
|
|
13
|
-
description:
|
|
14
12
|
email:
|
|
15
13
|
- zachpendleton@gmail.com
|
|
16
14
|
executables: []
|
|
@@ -47,7 +45,6 @@ licenses:
|
|
|
47
45
|
metadata:
|
|
48
46
|
homepage_uri: https://github.com/zachpendleton/rx
|
|
49
47
|
source_code_uri: https://github.com/zachpendleton/rx
|
|
50
|
-
post_install_message:
|
|
51
48
|
rdoc_options: []
|
|
52
49
|
require_paths:
|
|
53
50
|
- lib
|
|
@@ -62,8 +59,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
62
59
|
- !ruby/object:Gem::Version
|
|
63
60
|
version: '0'
|
|
64
61
|
requirements: []
|
|
65
|
-
rubygems_version: 3.
|
|
66
|
-
signing_key:
|
|
62
|
+
rubygems_version: 3.6.9
|
|
67
63
|
specification_version: 4
|
|
68
64
|
summary: Standard health checks for Rails and Rack applications
|
|
69
65
|
test_files: []
|