nutcracker-web 0.0.19 → 0.0.20
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/nutcracker/web/app.rb +13 -8
- data/lib/nutcracker/web/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f791f65c1eef5010bfe7e68837a32bd2c94af02f05ef47db3a898994e2c3d06c
|
4
|
+
data.tar.gz: 2e027d627de86005825a92ac848ab23d6cc156b7596e0bcfb53f4fc4e2cf2288
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f5d1d232ca769d9fade62e6a726fbefadb25b0ad1d1c4d6b8c7ff4ee0ee1d35417c949e55666d7023e976c5a9aa0c4af935c51db54a2445e5e8ec0fcbd1e566c
|
7
|
+
data.tar.gz: 96400c59ae25624bee9d33a2fb7bb54a86c4de65275a5181870c7e2b9864c806dc63ec6c3424a0426b19a20482c9bcd0fcc4b05628261a12864a0defe1c0c616
|
data/lib/nutcracker/web/app.rb
CHANGED
@@ -24,22 +24,27 @@ module Nutcracker
|
|
24
24
|
haml :index
|
25
25
|
end
|
26
26
|
|
27
|
-
get '/status' do
|
27
|
+
get '/status.json' do
|
28
|
+
content_type :json
|
28
29
|
# return array of maps each map is {instance_ip => [unresposive_node_ports],instance_ip => [unresposive_node_ports]}
|
29
30
|
# exaple: [{"127.0.0.1"=>["6370", "6371", "6372", "6373"]}, {"192.168.1.114"=>["6370"]}]
|
30
|
-
|
31
|
+
# return status 500 if there are unresposive_node in the list, if empty return 200
|
32
|
+
|
33
|
+
@nutcracker.
|
31
34
|
config.
|
32
35
|
values.
|
33
|
-
map {|x| x["servers"] + [x["listen"]]}.
|
36
|
+
map { |x| x["servers"] + [x["listen"]] }.
|
34
37
|
flatten.
|
35
|
-
map {|x| x.split(":")}.
|
36
|
-
map {|host, port| Thread.new {TCPSocket.new(host,port).close.nil? rescue
|
38
|
+
map { |x| x.split(":") }.
|
39
|
+
map { |host, port| Thread.new { { host: host, port: port, ok: (TCPSocket.new(host,port).close.nil? rescue false) } } }.
|
37
40
|
map(&:value).
|
41
|
+
flatten.
|
42
|
+
reject { |node_health| node_health[:ok]}. #cleare all healthy nodes from the nodes array
|
43
|
+
tap { |unhealthy_nodes| status(500) unless unhealthy_nodes.empty? }.
|
38
44
|
group_by{|k| k[:host]}.
|
39
45
|
map {|k,v| [k=>v.map { |v| v[:port] }] }.
|
40
|
-
flatten
|
41
|
-
|
42
|
-
status = unresponsive_ndoes.empty?.tap {|x| status(x ? 200 : 401)}
|
46
|
+
flatten.
|
47
|
+
to_json
|
43
48
|
end
|
44
49
|
|
45
50
|
get '/overview.json' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nutcracker-web
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.20
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eran Barak Levi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-12-
|
11
|
+
date: 2021-12-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|