Class: Discover::Client
Instance Method Summary collapse
-
#initialize(host = '127.0.0.1', port = 1111) ⇒ Client
constructor
A new instance of Client.
- #register(name, port = nil, ip = nil, attributes = {}) ⇒ Object
- #register_and_standby(name, port = nil, ip = nil, attributes = {}) ⇒ Object
- #remove_registration(reg) ⇒ Object
- #request(*args, &block) ⇒ Object
- #service(name, filters = {}) ⇒ Object
- #unregister_all ⇒ Object
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_all ⇒ Object
33 34 35 |
# File 'lib/discover.rb', line 33 def unregister_all @registrations.each(&:unregister) end |