Class: EMStatsd::TCPWrapper

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(host, port) ⇒ TCPWrapper

Returns a new instance of TCPWrapper.



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

def initialize(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.connect(host, port, EM::Connection)
end

Instance Attribute Details

#connectionObject (readonly)

Returns the value of attribute connection.



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

def connection
  @connection
end

Instance Method Details

#closeObject



13
14
15
# File 'lib/event_machine/em_statsd/tcp_wrapper.rb', line 13

def close
  connection.close_connection_after_writing
end

#flushObject



17
18
19
# File 'lib/event_machine/em_statsd/tcp_wrapper.rb', line 17

def flush

end

#write(message) ⇒ Object



21
22
23
# File 'lib/event_machine/em_statsd/tcp_wrapper.rb', line 21

def write(message)
  connection.send_data(message)
end