class Datadog::Contrib::Redis::Configuration::Resolver

Converts Symbols, Strings, and Hashes to a normalized connection settings Hash.

Public Instance Methods

connection_resolver() click to toggle source
# File lib/ddtrace/contrib/redis/configuration/resolver.rb, line 29
def connection_resolver
  @connection_resolver ||= ::Datadog::Contrib::Redis::Vendor::Resolver.new
end
normalize(hash) click to toggle source
# File lib/ddtrace/contrib/redis/configuration/resolver.rb, line 15
def normalize(hash)
  return { url: hash[:url] } if hash[:scheme] == 'unix'

  # Connexion strings are always converted to host, port, db and scheme
  # but the host, port, db and scheme will generate the :url only after
  # establishing a first connexion
  {
    host: hash[:host],
    port: hash[:port],
    db: hash[:db],
    scheme: hash[:scheme]
  }
end
resolve(key_or_hash) click to toggle source
# File lib/ddtrace/contrib/redis/configuration/resolver.rb, line 9
def resolve(key_or_hash)
  return :default if key_or_hash == :default

  normalize(connection_resolver.resolve(key_or_hash))
end