Class: StatsD::Instrument::UdpConnection

Inherits:
Object
  • Object
show all
Includes:
ConnectionBehavior
Defined in:
lib/statsd/instrument/udp_connection.rb

Constant Summary collapse

DEFAULT_MAX_PACKET_SIZE =
1_472

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ConnectionBehavior

#close, #send_buffer_size

Constructor Details

#initialize(host, port, max_packet_size: DEFAULT_MAX_PACKET_SIZE) ⇒ UdpConnection

Returns a new instance of UdpConnection.



12
13
14
15
16
# File 'lib/statsd/instrument/udp_connection.rb', line 12

def initialize(host, port, max_packet_size: DEFAULT_MAX_PACKET_SIZE)
  @host = host
  @port = port
  @max_packet_size = max_packet_size
end

Instance Attribute Details

#hostObject (readonly)

Returns the value of attribute host.



10
11
12
# File 'lib/statsd/instrument/udp_connection.rb', line 10

def host
  @host
end

#portObject (readonly)

Returns the value of attribute port.



10
11
12
# File 'lib/statsd/instrument/udp_connection.rb', line 10

def port
  @port
end

Instance Method Details

#send_datagram(message) ⇒ Object



18
19
20
# File 'lib/statsd/instrument/udp_connection.rb', line 18

def send_datagram(message)
  socket.send(message, 0)
end

#typeObject



22
23
24
# File 'lib/statsd/instrument/udp_connection.rb', line 22

def type
  :udp
end