Class: LogStash::Outputs::Tcp::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/logstash/outputs/tcp.rb

Instance Method Summary collapse

Constructor Details

#initialize(socket, logger) ⇒ Client

Returns a new instance of Client.



44
45
46
47
48
# File 'lib/logstash/outputs/tcp.rb', line 44

def initialize(socket, logger)
  @socket = socket
  @logger = logger
  @queue  = Queue.new
end

Instance Method Details

#runObject



51
52
53
54
55
56
57
58
59
60
61
# File 'lib/logstash/outputs/tcp.rb', line 51

def run
  loop do
    begin
      @socket.write(@queue.pop)
    rescue => e
      @logger.warn("tcp output exception", :socket => @socket,
                   :exception => e)
      break
    end
  end
end

#write(msg) ⇒ Object



64
65
66
# File 'lib/logstash/outputs/tcp.rb', line 64

def write(msg)
  @queue.push(msg)
end