rx-healthcheck 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rx/check/file_system_check.rb +8 -5
- data/lib/rx/check/generic_check.rb +6 -3
- data/lib/rx/check/http_check.rb +4 -3
- data/lib/rx/concurrent/thread_pool.rb +13 -1
- data/lib/rx/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9a5089cc2aca4dab181a11a5aa9a3135862d7de57976ded482366a9e147ac7a8
|
4
|
+
data.tar.gz: 4ec642b3e93f6b0f983cb7dff58b4bed8ede3e64dd7655bd1cac7f76583c7dfe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 439bc089d1ce63f1c63f687cdf0b8b473bbcb2f6bbf3c04a847905d176cdb667e6f6c3b6e754121af685b87fc2b00f318ca3e4c6fc2de17fd80cd4cd88693ff2
|
7
|
+
data.tar.gz: 37c97bcd6967d3d336e669d78b6474978771c0d7dbc79daca8276dd66484c2485398f1cc6bd888c5f46f63e4855c33c9b4bb70a7b7e042937b588259e7b61a0f
|
@@ -3,17 +3,20 @@ module Rx
|
|
3
3
|
class FileSystemCheck
|
4
4
|
FILENAME = "rx".freeze
|
5
5
|
|
6
|
-
attr_reader :name
|
6
|
+
attr_reader :name, :timeout
|
7
7
|
|
8
|
-
def initialize(name = "fs")
|
8
|
+
def initialize(name = "fs", timeout = 0)
|
9
9
|
@name = name
|
10
|
+
@timeout = 0
|
10
11
|
end
|
11
12
|
|
12
13
|
def check
|
13
14
|
Result.from(name) do
|
14
|
-
|
15
|
-
|
16
|
-
|
15
|
+
Timeout::timeout(timeout) do
|
16
|
+
!!Tempfile.open(FILENAME) do |f|
|
17
|
+
f.write("ok")
|
18
|
+
f.flush
|
19
|
+
end
|
17
20
|
end
|
18
21
|
end
|
19
22
|
end
|
@@ -1,16 +1,19 @@
|
|
1
|
+
require "timeout"
|
2
|
+
|
1
3
|
module Rx
|
2
4
|
module Check
|
3
5
|
class GenericCheck
|
4
|
-
attr_reader :name
|
6
|
+
attr_reader :name, :timeout
|
5
7
|
|
6
|
-
def initialize(callable, name = "generic")
|
8
|
+
def initialize(callable, name = "generic", timeout = 0)
|
7
9
|
@callable = callable
|
8
10
|
@name = name
|
11
|
+
@timeout = timeout
|
9
12
|
end
|
10
13
|
|
11
14
|
def check
|
12
15
|
Result.from(name) do
|
13
|
-
callable.call
|
16
|
+
Timeout::timeout(timeout) { callable.call }
|
14
17
|
end
|
15
18
|
end
|
16
19
|
|
data/lib/rx/check/http_check.rb
CHANGED
@@ -3,17 +3,18 @@ require "uri"
|
|
3
3
|
module Rx
|
4
4
|
module Check
|
5
5
|
class HttpCheck
|
6
|
-
attr_reader :name
|
6
|
+
attr_reader :name, :timeout
|
7
7
|
|
8
|
-
def initialize(url, name = "http")
|
8
|
+
def initialize(url, name = "http", timeout: 1)
|
9
9
|
@url = URI(url)
|
10
10
|
@name = name
|
11
|
+
@timeout = timeout
|
11
12
|
end
|
12
13
|
|
13
14
|
def check
|
14
15
|
Result.from(name) do
|
15
16
|
http = Net::HTTP.new(url.host, url.port)
|
16
|
-
http.read_timeout =
|
17
|
+
http.read_timeout = timeout
|
17
18
|
http.use_ssl = url.scheme == "https"
|
18
19
|
|
19
20
|
response = http.request(Net::HTTP::Get.new(path))
|
@@ -6,6 +6,7 @@ module Rx
|
|
6
6
|
def initialize(size = Etc.nprocessors)
|
7
7
|
@pool = []
|
8
8
|
@size = size
|
9
|
+
@pid = Process.pid
|
9
10
|
end
|
10
11
|
|
11
12
|
def shutdown
|
@@ -35,12 +36,23 @@ module Rx
|
|
35
36
|
end
|
36
37
|
|
37
38
|
def submit(&block)
|
39
|
+
restart_on_fork if forked?
|
40
|
+
|
38
41
|
return unless started?
|
39
42
|
queue << block
|
40
43
|
end
|
41
44
|
|
42
45
|
private
|
43
|
-
attr_reader :pool, :queue, :size
|
46
|
+
attr_reader :pid, :pool, :queue, :size
|
47
|
+
|
48
|
+
def forked?
|
49
|
+
Process.pid != pid
|
50
|
+
end
|
51
|
+
|
52
|
+
def restart_on_fork
|
53
|
+
restart
|
54
|
+
@pid = Process.pid
|
55
|
+
end
|
44
56
|
|
45
57
|
def worker
|
46
58
|
-> {
|
data/lib/rx/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +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.6
|
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-
|
11
|
+
date: 2021-09-29 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|
@@ -60,7 +60,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
requirements: []
|
63
|
-
rubygems_version: 3.1.
|
63
|
+
rubygems_version: 3.1.6
|
64
64
|
signing_key:
|
65
65
|
specification_version: 4
|
66
66
|
summary: Standard health checks for Rails and Rack applications
|