Class: Jerakia::Datasource::Consul_kv
- Defined in:
- lib/jerakia/datasource/consul_kv.rb
Instance Attribute Summary
Attributes inherited from Instance
Instance Method Summary collapse
-
#lookup ⇒ Object
Entrypoint for Jerakia lookups starts here.
Methods inherited from Instance
#answer, feature, #features?, #initialize, option, set_options, validate_options
Constructor Details
This class inherits a constructor from Jerakia::Datasource::Instance
Instance Method Details
#lookup ⇒ Object
Entrypoint for Jerakia lookups starts here.
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/jerakia/datasource/consul_kv.rb', line 51 def lookup Jerakia.log.debug("[datasource::console_kv] backend performing lookup for #{request.key}") paths = [:searchpath].reject { |p| p.nil? } key = request.key namespace = request.namespace answer do |response| break if paths.empty? path = paths.shift.split('/').compact path << namespace path << key unless key.nil? = { :recurse => [:recursive], :convert_to_hash => [:to_hash], :dc => [:datacenter], } begin key_path = path.flatten.join('/') Jerakia.log.debug("[datasource::consul_kv] Looking up #{key_path} with options #{}") result = Diplomat::Kv.get(key_path, ) rescue Diplomat::KeyNotFound => e Jerakia.log.debug("NotFound encountered, skipping to next path entry") next rescue Faraday::ConnectionFailed => e raise Jerakia::Error, "Failed to connect to consul service: #{e.}" end response.submit result end end |