philae 0.3.2 → 0.4.0
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/lib/philae/http_probe.rb +10 -1
- data/lib/philae/nsq_cluster_probe.rb +4 -4
- data/lib/philae/nsq_probe.rb +4 -3
- 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: 30d73e3e0425c11acc1fb1f03291b6d922b9141b077d5df15c82fd1bb654be9a
|
4
|
+
data.tar.gz: f2296b07a57836132bc39c34de390d54a19cf91b31fe91420629fac920ff1a5b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 80374b372327ad433cfe231df3cba1e555af3225b4bc0747c66fa304885f08242058666a8d7853e64751666d15cd419d2d72a805ca8a71be1b32779f532de46e
|
7
|
+
data.tar.gz: 68507be35885a378a305df2172a718c331e8b51b1bd7b2b5630228d10a4d1cc21ddb82c5eb28b4e59f167fea9d8847905140b0c566f065ef5b26597f1d10efe6
|
data/lib/philae/http_probe.rb
CHANGED
@@ -11,12 +11,13 @@ module Philae
|
|
11
11
|
# key: "path/to/key",
|
12
12
|
# ca: "path/to/ca"
|
13
13
|
# }
|
14
|
-
def initialize(name, uri, username = nil, password = nil, tls_context = nil)
|
14
|
+
def initialize(name, uri, username = nil, password = nil, tls_context = nil, timeout = nil)
|
15
15
|
@name = name
|
16
16
|
@uri = uri
|
17
17
|
@username = username
|
18
18
|
@password = password
|
19
19
|
@tls_context = tls_context
|
20
|
+
@timeout = timeout
|
20
21
|
end
|
21
22
|
|
22
23
|
def check
|
@@ -32,6 +33,14 @@ module Philae
|
|
32
33
|
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
33
34
|
end
|
34
35
|
end
|
36
|
+
|
37
|
+
if !@timeout.nil?
|
38
|
+
http.read_timeout = @timeout
|
39
|
+
http.open_timeout = @timeout
|
40
|
+
http.write_timeout = @timeout
|
41
|
+
http.ssl_timeout = @timeout
|
42
|
+
end
|
43
|
+
|
35
44
|
req = Net::HTTP::Get.new(uri)
|
36
45
|
req.basic_auth @username, @password if !@username.nil? || !@password.nil?
|
37
46
|
resp = http.start do |httpconn|
|
@@ -7,7 +7,7 @@ module Philae
|
|
7
7
|
|
8
8
|
attr_reader :name, :nsq_probes
|
9
9
|
|
10
|
-
def self.new_from_env(name)
|
10
|
+
def self.new_from_env(name, opts = {})
|
11
11
|
if ENV['NSQD_HOSTS'].nil? || ENV['NSQD_HTTP_PORT'].nil?
|
12
12
|
raise ArgumentError, 'no NSQD_HOSTS and NSQD_HTTP_PORT defined'
|
13
13
|
end
|
@@ -25,17 +25,17 @@ module Philae
|
|
25
25
|
host.split(':')[0] + ":#{ENV['NSQD_HTTP_PORT']}"
|
26
26
|
end
|
27
27
|
|
28
|
-
new(name, http_hosts, tls_context)
|
28
|
+
new(name, http_hosts, tls_context, opts)
|
29
29
|
end
|
30
30
|
|
31
|
-
def initialize(name, hosts, tls_context = nil)
|
31
|
+
def initialize(name, hosts, tls_context = nil, opts = {})
|
32
32
|
raise ArgumentError, 'should have at least one host' if hosts.nil? || hosts.empty?
|
33
33
|
|
34
34
|
@name = name
|
35
35
|
@nsq_probes = hosts.map do |hostport|
|
36
36
|
host, port = hostport.split(':')
|
37
37
|
port = DEFAULT_HTTP_PORT if port.nil?
|
38
|
-
next Philae::NSQProbe.new("#{name}-#{host}-#{port}", host, port, tls_context)
|
38
|
+
next Philae::NSQProbe.new("#{name}-#{host}-#{port}", host, port, tls_context, opts)
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
data/lib/philae/nsq_probe.rb
CHANGED
@@ -2,19 +2,19 @@ require File.join File.dirname(__FILE__), 'http_probe.rb'
|
|
2
2
|
|
3
3
|
module Philae
|
4
4
|
class NSQProbe < HttpProbe
|
5
|
-
def self.new_from_env(name)
|
5
|
+
def self.new_from_env(name, opts = {})
|
6
6
|
if ENV["NSQD_TLS"] == "true"
|
7
7
|
return self.new(name, ENV["NSQD_HOST"], ENV["NSQD_HTTP_PORT"], {
|
8
8
|
cert: ENV["NSQD_TLS_CERT"],
|
9
9
|
key: ENV["NSQD_TLS_KEY"],
|
10
10
|
ca: ENV["NSQD_TLS_CACERT"],
|
11
|
-
})
|
11
|
+
}, opts)
|
12
12
|
else
|
13
13
|
return self.new(name, ENV["NSQD_HOST"], ENV["NSQD_HTTP_PORT"])
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
-
def initialize(name, host, port = 4151, tls_context = nil)
|
17
|
+
def initialize(name, host, port = 4151, tls_context = nil, opts = {})
|
18
18
|
@name = name
|
19
19
|
scheme = "http"
|
20
20
|
if !tls_context.nil?
|
@@ -22,6 +22,7 @@ module Philae
|
|
22
22
|
end
|
23
23
|
@uri = "#{scheme}://#{host}:#{port}/ping"
|
24
24
|
@tls_context = tls_context
|
25
|
+
@timeout = opts.fetch(:timeout, 5)
|
25
26
|
end
|
26
27
|
end
|
27
28
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: philae
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- leo@scalingo.com
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2021-08-23 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: docker-api
|
@@ -120,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
120
120
|
- !ruby/object:Gem::Version
|
121
121
|
version: '0'
|
122
122
|
requirements: []
|
123
|
-
rubygems_version: 3.
|
123
|
+
rubygems_version: 3.1.4
|
124
124
|
signing_key:
|
125
125
|
specification_version: 4
|
126
126
|
summary: Provide an health check API
|