75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
# File 'lib/zipkin-query.rb', line 75
def self.get_query_service(zk_host, zk_port, opts={})
if opts[:skip_zookeeper]
return [ opts[:zipkin_query_host], opts[:zipkin_query_port] ]
end
node_path = opts[:node_path] || NODE_PATH
zk = Zookeeper.new("#{zk_host}:#{zk_port}")
begin
children = zk.get_children(:path => node_path)
node_key = children[:children][0]
node = zk.get(:path => "#{node_path}/#{node_key}")
ensure
zk.close() if zk
end
d = Thrift::Deserializer.new
si = d.deserialize(Twitter::Thrift::ServiceInstance.new, node[:data])
[si.serviceEndpoint.host, si.serviceEndpoint.port]
end
|