Class: Datadog::Contrib::Redis::Configuration::Resolver
- Inherits:
-
Configuration::Resolver
- Object
- Configuration::Resolver
- Datadog::Contrib::Redis::Configuration::Resolver
- Defined in:
- lib/ddtrace/contrib/redis/configuration/resolver.rb
Overview
Converts Symbols, Strings, and Hashes to a normalized connection settings Hash.
Instance Method Summary collapse
Methods inherited from Configuration::Resolver
Instance Method Details
#connection_resolver ⇒ Object
29 30 31 |
# File 'lib/ddtrace/contrib/redis/configuration/resolver.rb', line 29 def connection_resolver @connection_resolver ||= ::Datadog::Contrib::Redis::Vendor::Resolver.new end |
#normalize(hash) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# 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) ⇒ Object
9 10 11 12 13 |
# 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 |