class FlumeLogger::Eventserver
Public Class Methods
new(host="localhost", port=9090, flume_type=:ng)
click to toggle source
# File lib/flume-logger/eventserver.rb, line 2 def initialize(host="localhost", port=9090, flume_type=:ng) @host = host @port = port @client = nil @type = flume_type end
Public Instance Methods
close()
click to toggle source
# File lib/flume-logger/eventserver.rb, line 22 def close @client && @transport.close() rescue => e warn "#{self.class} - #{e.class} - #{e.message}" end
write(event)
click to toggle source
# File lib/flume-logger/eventserver.rb, line 9 def write(event) begin connect unless @client @client.append(event) rescue => e warn "#{self.class} - #{e.class} - #{e.message}: #{event}" close @client = nil raise end end
Private Instance Methods
connect()
click to toggle source
# File lib/flume-logger/eventserver.rb, line 29 def connect @client = case @type when :ng then @transport = Thrift::FramedTransport.new(Thrift::Socket.new(@host, @port)) protocol = Thrift::CompactProtocol.new(@transport) ThriftSourceProtocol::Client.new(protocol) when :og then @transport = Thrift::BufferedTransport.new(Thrift::Socket.new(@host, @port)) protocol = Thrift::BinaryProtocol.new(@transport) ThriftFlumeEventServer::Client.new(protocol) end @transport.open() end