Class: LogStash::Inputs::Websocket

Inherits:
Base show all
Defined in:
lib/logstash/inputs/websocket.rb

Overview

Read events over the websocket protocol.

Constant Summary

Constants included from Config::Mixin

Config::Mixin::CONFIGSORT

Instance Attribute Summary

Attributes inherited from Base

#params, #threadable

Attributes included from Config::Mixin

#config, #original_params

Attributes inherited from Plugin

#logger, #params

Instance Method Summary collapse

Methods inherited from Base

#initialize, #tag

Methods included from Config::Mixin

#config_init, included

Methods inherited from Plugin

#eql?, #finished, #finished?, #hash, #initialize, #inspect, lookup, #reload, #running?, #shutdown, #teardown, #terminating?, #to_s

Constructor Details

This class inherits a constructor from LogStash::Inputs::Base

Instance Method Details

#registerObject



26
27
28
# File 'lib/logstash/inputs/websocket.rb', line 26

def register
  require "ftw"
end

#run(output_queue) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/logstash/inputs/websocket.rb', line 31

def run(output_queue)
  # TODO(sissel): Implement server mode.
  agent = FTW::Agent.new
  begin
    websocket = agent.websocket!(@url)
    websocket.each do |payload|
      @codec.decode(payload) do |event|
        decorate(event)
        output_queue << event
      end
    end
  rescue => e
    @logger.warn("websocket input client threw exception, restarting",
                 :exception => e)
    sleep(1)
    retry
  end # begin
end