Class: Ocular::DSL::Orbit::OrbitFunctions

Inherits:
Object
  • Object
show all
Defined in:
lib/ocular/dsl/orbit.rb

Instance Method Summary collapse

Constructor Details

#initialize(etcd) ⇒ OrbitFunctions

Returns a new instance of OrbitFunctions.



11
12
13
# File 'lib/ocular/dsl/orbit.rb', line 11

def initialize(etcd)
    @etcd = etcd
end

Instance Method Details

#get_service_endpoints(service_name) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/ocular/dsl/orbit.rb', line 16

def get_service_endpoints(service_name)
    orbit_endpoints = []
    begin
        endpoints = @etcd.get("/orbit/services/#{service_name}/endpoints").node.children
        endpoints.each do |node|
          ip = node.key.match(/.*endpoints.(.+?):.+/).captures[0]
          orbit_endpoints << ip
        end
    rescue ::Etcd::KeyNotFound
        return []
    end

    return orbit_endpoints
end