Class: LogStash::Inputs::Tcp
Defined Under Namespace
Classes: TCPInput
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(url, type, config = {}, &block) ⇒ Tcp
constructor
A new instance of Tcp.
- #receive(host, port, event) ⇒ Object
- #register ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(url, type, config = {}, &block) ⇒ Tcp
Returns a new instance of Tcp.
8 9 10 |
# File 'lib/logstash/inputs/tcp.rb', line 8 def initialize(url, type, config={}, &block) super end |
Instance Method Details
#receive(host, port, event) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/logstash/inputs/tcp.rb', line 25 def receive(host, port, event) url = @url.clone url.host = host url.port = port @logger.debug(["original url", { :originalurl => @url, :newurl => url }]) event = LogStash::Event.new({ "@message" => event, "@type" => @type, "@tags" => @tags.clone, }) event.source = url @logger.debug(["Got event", event]) @callback.call(event) end |
#register ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/logstash/inputs/tcp.rb', line 13 def register if !@url.host or !@url.port @logger.fatal("No host or port given in #{self.class}: #{@url}") # TODO(sissel): Make this an actual exception class raise "configuration error" end @logger.info("Starting tcp listener for #{@url}") EventMachine::start_server(@url.host, @url.port, TCPInput, @url, self, @logger) end |