Class: Discover::Client

Inherits:
Object
  • Object
show all
Includes:
Celluloid
Defined in:
lib/discover.rb

Instance Method Summary collapse

Constructor Details

#initialize(host = '127.0.0.1', port = 1111) ⇒ Client

Returns a new instance of Client.



8
9
10
11
# File 'lib/discover.rb', line 8

def initialize(host='127.0.0.1', port=1111)
  @client        = RPCPlus::Client.new(host, port)
  @registrations = []
end

Instance Method Details

#register(name, port = nil, ip = nil, attributes = {}) ⇒ Object



21
22
23
# File 'lib/discover.rb', line 21

def register(name, port=nil, ip=nil, attributes={})
  _register(name, port, ip, attributes, false)
end

#register_and_standby(name, port = nil, ip = nil, attributes = {}) ⇒ Object



25
26
27
# File 'lib/discover.rb', line 25

def register_and_standby(name, port=nil, ip=nil, attributes={})
  _register(name, port, ip, attributes, true)
end

#remove_registration(reg) ⇒ Object



29
30
31
# File 'lib/discover.rb', line 29

def remove_registration(reg)
  @registrations.delete(reg)
end

#request(*args, &block) ⇒ Object



13
14
15
# File 'lib/discover.rb', line 13

def request(*args, &block)
  @client.request(*args, &block)
end

#service(name, filters = {}) ⇒ Object



17
18
19
# File 'lib/discover.rb', line 17

def service(name, filters={})
  Service.new(self, name, filters)
end

#unregister_allObject



33
34
35
# File 'lib/discover.rb', line 33

def unregister_all
  @registrations.each(&:unregister)
end