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.



58
59
60
61
62
# File 'lib/logstash/outputs/tcp.rb', line 58

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

Instance Method Details

#runObject



65
66
67
68
69
70
71
72
73
74
75
# File 'lib/logstash/outputs/tcp.rb', line 65

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



78
79
80
# File 'lib/logstash/outputs/tcp.rb', line 78

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