Sha256: 11d22a395e3372072f1eb5d892462b6c981e7b999072480a48100aefdc92a959

Contents?: true

Size: 1.33 KB

Versions: 24

Compression:

Stored size: 1.33 KB

Contents

require_relative '../vendor/resolver'

module Datadog
  module Tracing
    module Contrib
      module Redis
        module Configuration
          UNIX_SCHEME = 'unix'.freeze

          # Converts String URLs and Hashes to a normalized connection settings Hash.
          class Resolver < Contrib::Configuration::Resolver
            # @param [Hash,String] Redis connection information
            def resolve(hash)
              super(parse_matcher(hash))
            end

            protected

            def parse_matcher(matcher)
              matcher = { url: matcher } if matcher.is_a?(String)

              normalize(connection_resolver.resolve(matcher))
            end

            def normalize(hash)
              return { url: hash[:url] } if hash[:scheme] == UNIX_SCHEME

              # 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

            def connection_resolver
              @connection_resolver ||= Vendor::Resolver.new
            end
          end
        end
      end
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
ddtrace-1.23.3 lib/datadog/tracing/contrib/redis/configuration/resolver.rb
ddtrace-1.23.2 lib/datadog/tracing/contrib/redis/configuration/resolver.rb
ddtrace-1.23.1 lib/datadog/tracing/contrib/redis/configuration/resolver.rb
ddtrace-1.22.0 lib/datadog/tracing/contrib/redis/configuration/resolver.rb
ddtrace-1.21.1 lib/datadog/tracing/contrib/redis/configuration/resolver.rb
ddtrace-1.21.0 lib/datadog/tracing/contrib/redis/configuration/resolver.rb
ddtrace-1.20.0 lib/datadog/tracing/contrib/redis/configuration/resolver.rb
ddtrace-1.19.0 lib/datadog/tracing/contrib/redis/configuration/resolver.rb
ddtrace-1.18.0 lib/datadog/tracing/contrib/redis/configuration/resolver.rb
ddtrace-1.17.0 lib/datadog/tracing/contrib/redis/configuration/resolver.rb
ddtrace-1.16.2 lib/datadog/tracing/contrib/redis/configuration/resolver.rb
ddtrace-1.16.1 lib/datadog/tracing/contrib/redis/configuration/resolver.rb
ddtrace-1.16.0 lib/datadog/tracing/contrib/redis/configuration/resolver.rb
ddtrace-1.15.0 lib/datadog/tracing/contrib/redis/configuration/resolver.rb
ddtrace-1.14.0 lib/datadog/tracing/contrib/redis/configuration/resolver.rb
ddtrace-1.13.1 lib/datadog/tracing/contrib/redis/configuration/resolver.rb
ddtrace-1.13.0 lib/datadog/tracing/contrib/redis/configuration/resolver.rb
ddtrace-1.12.1 lib/datadog/tracing/contrib/redis/configuration/resolver.rb
ddtrace-1.12.0 lib/datadog/tracing/contrib/redis/configuration/resolver.rb
ddtrace-1.11.1 lib/datadog/tracing/contrib/redis/configuration/resolver.rb