class ConsulApplicationSettings::Providers::ConsulPreloaded

Provides access to settings stored in Consul. Loads them once

Public Class Methods

new(base_path, config) click to toggle source
# File lib/consul_application_settings/providers/consul_preloaded.rb, line 5
def initialize(base_path, config)
  super
  @data = get_all_from_consul
end

Public Instance Methods

get(path) click to toggle source
# File lib/consul_application_settings/providers/consul_preloaded.rb, line 10
def get(path)
  value = get_value_from_hash(absolute_key_path(path), @data)
  ConsulApplicationSettings::Utils.cast_consul_value(value)
end

Protected Instance Methods

get_all_from_consul() click to toggle source
# File lib/consul_application_settings/providers/consul_preloaded.rb, line 17
def get_all_from_consul
  Diplomat::Kv.get_all(@base_path, { convert_to_hash: true })
rescue Diplomat::KeyNotFound
  {}
rescue SystemCallError, Faraday::ConnectionFailed, Diplomat::PathNotFound => e
  raise e unless @config.disable_consul_connection_errors
  {}
end