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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2e70d2a5e6a87730d2ad90905a8da57cf3269475dc85be6666306283fe5296df
4
- data.tar.gz: a9f60bf120fa16a5ce1413d0c465044e75f9b1fcb157e932a1b6f7ec3b36c47e
3
+ metadata.gz: f791f65c1eef5010bfe7e68837a32bd2c94af02f05ef47db3a898994e2c3d06c
4
+ data.tar.gz: 2e027d627de86005825a92ac848ab23d6cc156b7596e0bcfb53f4fc4e2cf2288
5
5
  SHA512:
6
- metadata.gz: 8498dfc5396afc100f27b84ff3fe9a47d4384b0c60388bf8d85b2ae89fcc7719ca9a2b390813f4a1dc2294a032ac23d39dd18f21a4ac9e64d7926b5287585e3b
7
- data.tar.gz: cfa689fb43a17c8de1b277beb4b3bf40881916257e5f6652cd1a38f6707ef39424a1827d906d26151959bef4074b569383183fa9a7d2c49ca138cbc2726e5295
6
+ metadata.gz: f5d1d232ca769d9fade62e6a726fbefadb25b0ad1d1c4d6b8c7ff4ee0ee1d35417c949e55666d7023e976c5a9aa0c4af935c51db54a2445e5e8ec0fcbd1e566c
7
+ data.tar.gz: 96400c59ae25624bee9d33a2fb7bb54a86c4de65275a5181870c7e2b9864c806dc63ec6c3424a0426b19a20482c9bcd0fcc4b05628261a12864a0defe1c0c616
@@ -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
- unresponsive_ndoes = @nutcracker.
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 {:host=>host,:port=>port} } }.
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
- #if there are unresposive_node in the list return status 401, if empty return 200
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
@@ -1,5 +1,5 @@
1
1
  module Nutcracker
2
2
  module Web
3
- VERSION="0.0.19"
3
+ VERSION="0.0.20"
4
4
  end
5
5
  end
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.19
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-07 00:00:00.000000000 Z
11
+ date: 2021-12-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest