Class: Discover::Client
Instance Method Summary collapse
-
#initialize(address = nil) ⇒ 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(address = nil) ⇒ Client
Returns a new instance of Client.
8 9 10 11 12 13 |
# File 'lib/discover.rb', line 8 def initialize(address = nil) uri = parse(address || ENV["DISCOVERD"] || "127.0.0.1:1111") @client = RPCPlus::Client.new(uri.host, uri.port) @registrations = [] end |
Instance Method Details
#register(name, port = nil, ip = nil, attributes = {}) ⇒ Object
23 24 25 |
# File 'lib/discover.rb', line 23 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
27 28 29 |
# File 'lib/discover.rb', line 27 def register_and_standby(name, port=nil, ip=nil, attributes={}) _register(name, port, ip, attributes, true) end |
#remove_registration(reg) ⇒ Object
31 32 33 |
# File 'lib/discover.rb', line 31 def remove_registration(reg) @registrations.delete(reg) end |
#request(*args, &block) ⇒ Object
15 16 17 |
# File 'lib/discover.rb', line 15 def request(*args, &block) @client.request(*args, &block) end |
#service(name, filters = {}) ⇒ Object
19 20 21 |
# File 'lib/discover.rb', line 19 def service(name, filters={}) Service.new(self, name, filters) end |
#unregister_all ⇒ Object
35 36 37 |
# File 'lib/discover.rb', line 35 def unregister_all @registrations.each(&:unregister) end |