Class: EMStatsd::UDPWrapper

Inherits:
Object
  • Object
show all
Defined in:
lib/event_machine/em_statsd/udp_wrapper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(host, port) ⇒ UDPWrapper

Returns a new instance of UDPWrapper.



6
7
8
9
10
11
12
# File 'lib/event_machine/em_statsd/udp_wrapper.rb', line 6

def initialize(host, port)
  @host, @port = host, port
  # eventmachine forces us to listen on a UDP socket even
  # though we only
  # want to send, so we'll just give it a junk address
  @connection = EM.open_datagram_socket('0.0.0.0', 0, EM::Connection)
end

Instance Attribute Details

#connectionObject (readonly)

Returns the value of attribute connection.



4
5
6
# File 'lib/event_machine/em_statsd/udp_wrapper.rb', line 4

def connection
  @connection
end

Instance Method Details

#closeObject



14
15
16
# File 'lib/event_machine/em_statsd/udp_wrapper.rb', line 14

def close
  connection.close_connection_after_writing
end

#flushObject



18
19
20
# File 'lib/event_machine/em_statsd/udp_wrapper.rb', line 18

def flush

end

#write(message) ⇒ Object



22
23
24
# File 'lib/event_machine/em_statsd/udp_wrapper.rb', line 22

def write(message)
  connection.send_datagram(message, @host, @port)
end