Class: Datadog::Core::Configuration::AgentSettingsResolver::AgentSettings

Inherits:
Object
  • Object
show all
Defined in:
lib/datadog/core/configuration/agent_settings_resolver.rb

Overview

Immutable container for the resulting settings

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(adapter: nil, ssl: nil, hostname: nil, port: nil, uds_path: nil, timeout_seconds: nil) ⇒ AgentSettings

Returns a new instance of AgentSettings.



26
27
28
29
30
31
32
33
34
# File 'lib/datadog/core/configuration/agent_settings_resolver.rb', line 26

def initialize(adapter: nil, ssl: nil, hostname: nil, port: nil, uds_path: nil, timeout_seconds: nil)
  @adapter = adapter
  @ssl = ssl
  @hostname = hostname
  @port = port
  @uds_path = uds_path
  @timeout_seconds = timeout_seconds
  freeze
end

Instance Attribute Details

#adapterObject (readonly)

Returns the value of attribute adapter.



24
25
26
# File 'lib/datadog/core/configuration/agent_settings_resolver.rb', line 24

def adapter
  @adapter
end

#hostnameObject (readonly)

Returns the value of attribute hostname.



24
25
26
# File 'lib/datadog/core/configuration/agent_settings_resolver.rb', line 24

def hostname
  @hostname
end

#portObject (readonly)

Returns the value of attribute port.



24
25
26
# File 'lib/datadog/core/configuration/agent_settings_resolver.rb', line 24

def port
  @port
end

#sslObject (readonly)

Returns the value of attribute ssl.



24
25
26
# File 'lib/datadog/core/configuration/agent_settings_resolver.rb', line 24

def ssl
  @ssl
end

#timeout_secondsObject (readonly)

Returns the value of attribute timeout_seconds.



24
25
26
# File 'lib/datadog/core/configuration/agent_settings_resolver.rb', line 24

def timeout_seconds
  @timeout_seconds
end

#uds_pathObject (readonly)

Returns the value of attribute uds_path.



24
25
26
# File 'lib/datadog/core/configuration/agent_settings_resolver.rb', line 24

def uds_path
  @uds_path
end

Instance Method Details

#==(other) ⇒ Object



49
50
51
52
53
54
55
56
57
# File 'lib/datadog/core/configuration/agent_settings_resolver.rb', line 49

def ==(other)
  self.class == other.class &&
    adapter == other.adapter &&
    ssl == other.ssl &&
    hostname == other.hostname &&
    port == other.port &&
    uds_path == other.uds_path &&
    timeout_seconds == other.timeout_seconds
end

#urlObject



36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/datadog/core/configuration/agent_settings_resolver.rb', line 36

def url
  case adapter
  when Datadog::Core::Configuration::Ext::Agent::HTTP::ADAPTER
    hostname = self.hostname
    hostname = "[#{hostname}]" if hostname =~ IPV6_REGEXP
    "#{ssl ? 'https' : 'http'}://#{hostname}:#{port}/"
  when Datadog::Core::Configuration::Ext::Agent::UnixSocket::ADAPTER
    "unix://#{uds_path}"
  else
    raise ArgumentError, "Unexpected adapter: #{adapter}"
  end
end