Class: UAT::Discovery::Client

Inherits:
Interfaces::IClient show all
Defined in:
lib/uat/discovery/client.rb

Overview

A discovery client that uses Diplomat to get urls for a named service

See Also:

  • [UAT[UAT::Discovery[UAT::Discovery::IClient]

Instance Method Summary collapse

Constructor Details

#initialize(diplomat_service, protocol, api, path_provider) ⇒ Client

Returns a new instance of Client.

Parameters:

  • diplomat_service (Class<Diplomat::Service>)

    the diplomat service class reference

  • protocol (String)

    the protocol that should be prepended to urls_for_service

  • api (#new_uri)

    a factory method for creating new URIs

  • path_provider (UAT::Discovery::Interfaces::IPathProvider)

    provides path for after host/port



10
11
12
13
14
15
# File 'lib/uat/discovery/client.rb', line 10

def initialize(diplomat_service, protocol, api, path_provider)
  @diplomat_service = diplomat_service
  @protocol = protocol
  @api = api
  @path_provider = path_provider
end

Instance Method Details

#urls_for_service(service_name) ⇒ Object

See Also:

  • UAT::Discovery::Client.[UAT[UAT::Discovery[UAT::Discovery::IClient]


18
19
20
21
22
# File 'lib/uat/discovery/client.rb', line 18

def urls_for_service(service_name)
  diplomat_services = @diplomat_service.get(service_name, :all)
  path = @path_provider.path_to_append_for(service_name)
  diplomat_services.map {|diplomat_service| @api.new_uri(uri_string(diplomat_service, path)) }.uniq
end