class Graphite::Socket

Attributes

host[RW]
port[RW]
socket[RW]
type[RW]

Public Class Methods

new(host, port, socket_type) click to toggle source
# File lib/graphite/socket.rb, line 7
def initialize(host, port, socket_type)
  @host = host
  @port = port
  @type = socket_type
  @socket = nil
end

Public Instance Methods

close() click to toggle source
# File lib/graphite/socket.rb, line 19
def close
  @socket.close if @socket and !@socket.closed?
rescue => e
  warn "#{self.class} - #{e.class} - #{e.message}"
end
connect() click to toggle source

Retained for compatibility

# File lib/graphite/socket.rb, line 40
def connect
  socket
end
puts(event) click to toggle source
# File lib/graphite/socket.rb, line 14
def puts(event)
  socket.write(terminated_event(event.to_s))
  close if @type == :udp
end
terminated_event(event) click to toggle source
# File lib/graphite/socket.rb, line 35
def terminated_event(event)
  event =~ /\n$/ ? event : event + "\n"
end