Class: DiscoClient
Constant Summary collapse
- DEFAULT_CONTAINER =
{ id: ENV['CONTAINER_NAME'], type: 'http', port: 3000 }
Instance Method Summary collapse
- #get_configuration(id = nil) ⇒ Object
- #get_container(id = nil) ⇒ Object
- #get_service(id) ⇒ Object
- #get_services ⇒ Object
-
#initialize(options = {}) ⇒ DiscoClient
constructor
A new instance of DiscoClient.
- #register(service_id, options = {}) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ DiscoClient
Returns a new instance of DiscoClient.
17 18 19 |
# File 'lib/disco_client.rb', line 17 def initialize( = {}) @base_uri = [:base_uri] || ENV['DISCO_BASE_URI'] end |
Instance Method Details
#get_configuration(id = nil) ⇒ Object
42 43 44 45 |
# File 'lib/disco_client.rb', line 42 def get_configuration(id = nil) id = URI.encode_www_form_component(id || @container[:id]) request('get', "1/containers/#{id}/configuration") end |
#get_container(id = nil) ⇒ Object
37 38 39 40 |
# File 'lib/disco_client.rb', line 37 def get_container(id = nil) id = URI.encode_www_form_component(id || @container[:id]) request('get', "1/containers/#{id}") end |
#get_service(id) ⇒ Object
32 33 34 35 |
# File 'lib/disco_client.rb', line 32 def get_service(id) URI.encode_www_form_component(id) request('get', "1/services/#{id}") end |
#get_services ⇒ Object
28 29 30 |
# File 'lib/disco_client.rb', line 28 def get_services request('get', '1/services') end |
#register(service_id, options = {}) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/disco_client.rb', line 21 def register(service_id, = {}) body = DEFAULT_CONTAINER.merge() body[:service] = { id: service_id }; @container = request('post', '1/containers', nil, body) end |