rx-healthcheck 0.1.0 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/Gemfile +2 -1
- data/Gemfile.lock +3 -3
- data/lib/rx/check/result.rb +2 -2
- data/lib/rx/concurrent/future.rb +4 -0
- data/lib/rx/concurrent/thread_pool.rb +5 -0
- data/lib/rx/middleware.rb +9 -5
- data/lib/rx/version.rb +1 -1
- data/rx.gemspec +0 -2
- metadata +3 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 413f9d8b2e63ed831d68f8da5bfcfc32e40ca7eb93cf2b7a591c442d3bc2e205
|
4
|
+
data.tar.gz: d455aa46093f8d43b0c8be1d6464837f14603b1f44eadbf9078e1159a1bca9c3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2fdf00d9d3110daec49fef3c4aab4c1cd902d7d516283d361c5b78b28909c343d2fc1af87c4be9557b090783f3d6fbb3b17d0987e6f00ee26cad5e6d7564f488
|
7
|
+
data.tar.gz: 5f94fbdedc4f8d88b89332ffc544a2f1655a962c3f166a34f6d938c36bb77a733317cf0b4bbb6adaa76abc98a40d3ec317291ab76e3496f4600cca348cc1462c
|
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
rx (0.1.
|
5
|
-
simplecov (= 0.21.2)
|
4
|
+
rx-healthcheck (0.1.4)
|
6
5
|
|
7
6
|
GEM
|
8
7
|
remote: https://rubygems.org/
|
@@ -23,7 +22,8 @@ PLATFORMS
|
|
23
22
|
DEPENDENCIES
|
24
23
|
minitest (~> 5.0)
|
25
24
|
rake (~> 13.0)
|
26
|
-
rx!
|
25
|
+
rx-healthcheck!
|
26
|
+
simplecov (= 0.21.2)
|
27
27
|
|
28
28
|
BUNDLED WITH
|
29
29
|
2.2.11
|
data/lib/rx/check/result.rb
CHANGED
@@ -2,7 +2,7 @@ module Rx
|
|
2
2
|
module Check
|
3
3
|
class Result
|
4
4
|
def self.from(check_name)
|
5
|
-
start_at =
|
5
|
+
start_at = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
6
6
|
err = nil
|
7
7
|
result = false
|
8
8
|
|
@@ -12,7 +12,7 @@ module Rx
|
|
12
12
|
err = ex
|
13
13
|
end
|
14
14
|
|
15
|
-
end_at =
|
15
|
+
end_at = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
16
16
|
|
17
17
|
Result.new(check_name, result, ((end_at - start_at) * 1000).round(2), err)
|
18
18
|
end
|
data/lib/rx/concurrent/future.rb
CHANGED
data/lib/rx/middleware.rb
CHANGED
@@ -14,7 +14,7 @@ module Rx
|
|
14
14
|
options: {})
|
15
15
|
@app = app
|
16
16
|
@options = DEFAULT_OPTIONS.merge(options)
|
17
|
-
@cache = cache_factory(
|
17
|
+
@cache = cache_factory(@options)
|
18
18
|
|
19
19
|
@liveness_checks = liveness
|
20
20
|
@readiness_checks = readiness
|
@@ -23,11 +23,11 @@ module Rx
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def call(env)
|
26
|
-
unless health_check_request?(env)
|
26
|
+
unless health_check_request?(path(env))
|
27
27
|
return app.call(env)
|
28
28
|
end
|
29
29
|
|
30
|
-
case env
|
30
|
+
case path(env)
|
31
31
|
when "/liveness"
|
32
32
|
ok = check_to_component(liveness_checks).map { |x| x[:status] == 200 }.all?
|
33
33
|
liveness_response(ok)
|
@@ -57,14 +57,18 @@ module Rx
|
|
57
57
|
Rx::Cache::InMemoryCache.new
|
58
58
|
end
|
59
59
|
|
60
|
-
def health_check_request?(
|
61
|
-
%w[/liveness /readiness /deep].include?(
|
60
|
+
def health_check_request?(path)
|
61
|
+
%w[/liveness /readiness /deep].include?(path)
|
62
62
|
end
|
63
63
|
|
64
64
|
def liveness_response(is_ok)
|
65
65
|
[is_ok ? 200 : 503, {}, []]
|
66
66
|
end
|
67
67
|
|
68
|
+
def path(env)
|
69
|
+
env["PATH_INFO"] || env["REQUEST_PATH"] || env["REQUEST_URI"]
|
70
|
+
end
|
71
|
+
|
68
72
|
def readiness_response(components)
|
69
73
|
status = components.map { |x| x[:status] == 200 }.all? ? 200 : 503
|
70
74
|
|
data/lib/rx/version.rb
CHANGED
data/rx.gemspec
CHANGED
@@ -25,8 +25,6 @@ Gem::Specification.new do |spec|
|
|
25
25
|
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
26
26
|
spec.require_paths = ["lib"]
|
27
27
|
|
28
|
-
spec.add_dependency "simplecov", "0.21.2"
|
29
|
-
|
30
28
|
# For more information and examples about making a new gem, checkout our
|
31
29
|
# guide at: https://bundler.io/guides/creating_gem.html
|
32
30
|
end
|
metadata
CHANGED
@@ -1,29 +1,15 @@
|
|
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.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zach Pendleton
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
12
|
-
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: simplecov
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - '='
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: 0.21.2
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - '='
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: 0.21.2
|
11
|
+
date: 2021-07-07 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
27
13
|
description:
|
28
14
|
email:
|
29
15
|
- zachpendleton@gmail.com
|