Class: StatsD::Instrument::UdpConnection

Inherits:
Object
  • Object
show all
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

Constructor Details

#initialize(host, port) ⇒ UdpConnection

Returns a new instance of UdpConnection.



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

def initialize(host, port)
  @host = host
  @port = port
end

Instance Attribute Details

#hostObject (readonly)

Returns the value of attribute host.



8
9
10
# File 'lib/statsd/instrument/udp_connection.rb', line 8

def host
  @host
end

#portObject (readonly)

Returns the value of attribute port.



8
9
10
# File 'lib/statsd/instrument/udp_connection.rb', line 8

def port
  @port
end

Instance Method Details

#closeObject



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

def close
  @socket&.close
  @socket = nil
end

#send_datagram(message) ⇒ Object



15
16
17
# File 'lib/statsd/instrument/udp_connection.rb', line 15

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

#typeObject



24
25
26
# File 'lib/statsd/instrument/udp_connection.rb', line 24

def type
  :udp
end