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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ebf9af8d3b43d1640503ddcba7138d1ef6c04f298faa09b39c8d93fcb0d4eb50
4
- data.tar.gz: e22f89c795207f5a3a78bb6f63c362624e6b4104e3834f6ca928ecb1c6fd5b79
3
+ metadata.gz: 0a13e928ecfa7c5c8682acbe7a23dd10d4436eab15bde8b90814292f1a272505
4
+ data.tar.gz: 8bde613b1ff1c3dc35dae09301daaf08556219119f0d0e02e03e5e37addfb715
5
5
  SHA512:
6
- metadata.gz: a194f56c544904474062a866aa7c91cfe6de9548b97802beaa448b4b082dab4c1fc3ffa7f41e3c0aa14b8f94c11d518e586d6984f1a82cbfaf0d2479abc9ce06
7
- data.tar.gz: 1fc1ea21c9586cb3583d25ab7c8ab7177d0789ec085cc4de316dd136ebeb3c03872f30c2b54293c2efd254ea5ebae6d0255d86816488020a584e7c1b8c8b39f9
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.0"
8
+ gem "rake", "~> 13.3"
9
9
 
10
- gem "minitest", "~> 5.0"
11
- gem "simplecov", "0.21.2"
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.8)
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 (5.14.4)
11
- rake (13.0.3)
12
- simplecov (0.21.2)
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 (~> 5.0)
25
- rake (~> 13.0)
27
+ minitest (~> 6)
28
+ minitest-mock (~> 5)
29
+ rake (~> 13.3)
26
30
  rx-healthcheck!
27
- simplecov (= 0.21.2)
31
+ simplecov (= 0.22)
28
32
 
29
33
  BUNDLED WITH
30
- 2.2.29
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 "/liveness"
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 "/readiness"
38
+ when @options[:readiness_path]
36
39
  readiness_response(check_to_component(readiness_checks))
37
- when "/deep"
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
- %w[/liveness /readiness /deep].include?(path)
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Rx
4
- VERSION = "0.1.9"
4
+ VERSION = "0.1.11"
5
5
  end
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.9
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: 2022-04-27 00:00:00.000000000 Z
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.1.6
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: []