Class: EMStatsd::UDPWrapper
- Inherits:
-
Object
- Object
- EMStatsd::UDPWrapper
- Defined in:
- lib/event_machine/em_statsd/udp_wrapper.rb
Instance Attribute Summary collapse
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
Instance Method Summary collapse
- #close ⇒ Object
- #flush ⇒ Object
-
#initialize(host, port) ⇒ UDPWrapper
constructor
A new instance of UDPWrapper.
- #write(message) ⇒ Object
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
#connection ⇒ Object (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
#close ⇒ Object
14 15 16 |
# File 'lib/event_machine/em_statsd/udp_wrapper.rb', line 14 def close connection.close_connection_after_writing end |
#flush ⇒ Object
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() connection.send_datagram(, @host, @port) end |