Class: Datadog::Statsd::ConnectionCfg

Inherits:
Object
  • Object
show all
Defined in:
lib/datadog/statsd/connection_cfg.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(host: nil, port: nil, socket_path: nil) ⇒ ConnectionCfg

Returns a new instance of ConnectionCfg.



9
10
11
12
13
# File 'lib/datadog/statsd/connection_cfg.rb', line 9

def initialize(host: nil, port: nil, socket_path: nil)
  initialize_with_constructor_args(host: host, port: port, socket_path: socket_path) ||
    initialize_with_env_vars ||
    initialize_with_defaults
end

Instance Attribute Details

#hostObject (readonly)

Returns the value of attribute host.



4
5
6
# File 'lib/datadog/statsd/connection_cfg.rb', line 4

def host
  @host
end

#portObject (readonly)

Returns the value of attribute port.



5
6
7
# File 'lib/datadog/statsd/connection_cfg.rb', line 5

def port
  @port
end

#socket_pathObject (readonly)

Returns the value of attribute socket_path.



6
7
8
# File 'lib/datadog/statsd/connection_cfg.rb', line 6

def socket_path
  @socket_path
end

#transport_typeObject (readonly)

Returns the value of attribute transport_type.



7
8
9
# File 'lib/datadog/statsd/connection_cfg.rb', line 7

def transport_type
  @transport_type
end

Instance Method Details

#make_connection(**params) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/datadog/statsd/connection_cfg.rb', line 15

def make_connection(**params)
  case @transport_type
  when :udp
    UDPConnection.new(@host, @port, **params)
  when :uds
    UDSConnection.new(@socket_path, **params)
  end
end