Class: UAT::Discovery::ConsulPathProvider

Inherits:
Interfaces::IPathProvider show all
Defined in:
lib/uat/discovery/consul_path_provider.rb

Instance Method Summary collapse

Constructor Details

#initialize(diplomat_module, service_metadata_key_value_prefix, json_parser, metadata_property_for_path) ⇒ ConsulPathProvider

Returns a new instance of ConsulPathProvider.

Parameters:

  • diplomat_service (Module<Diplomat>)

    the diplomat module

  • service_metadata_key_value_prefix (String)

    the key value prefix that comes before a service name

  • json_parser (JSON)

    native JSON module or compatible parser

  • metadata_property_for_path (String)

    the property on the metadata node containing the path



8
9
10
11
12
13
# File 'lib/uat/discovery/consul_path_provider.rb', line 8

def initialize(diplomat_module, , json_parser, )
  @diplomat_module = diplomat_module
  @service_metadata_key_value_prefix = 
  @json_parser = json_parser
  @metadata_property_for_path = 
end

Instance Method Details

#path_to_append_for(service_name) ⇒ String

Parameters:

  • service_name (String)

    the name of the service for which one would like to get the path - ignored

Returns:

  • (String)


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

def path_to_append_for(service_name)
  #'chef/services/lookout-bluffdale'
   = @diplomat_module.get("#{@service_metadata_key_value_prefix}#{service_name}")
   = @json_parser.parse()
  ['metadata'][@metadata_property_for_path]
end