class Fusuma::Plugin::Inputs::Input
@abstract Subclass and override {#io} to implement
Inherite this base
def self.select(inputs)
-
(Event)-
Parameters:
-
inputs(Array) --
def self.select(inputs) ios = IO.select(inputs.map(&:io)) io = ios&.first&.first input = inputs.find { |i| i.io == io } begin line = io.readline_nonblock("\n").chomp rescue EOFError => e warn "#{input.class.name}: #{e}" warn 'Send SIGKILL to fusuma processes' inputs.reject { |i| i == input }.each do |i| warn "stop process: #{i.class.name.underscore}" Process.kill(:SIGKILL, i.pid) end exit 1 rescue StandardError => e warn "#{input.class.name}: #{e}" exit 1 end input.create_event(record: line) end
def create_event(record: 'dummy input')
-
(Event)-
def create_event(record: 'dummy input') e = Events::Event.new(tag: tag, record: record) MultiLogger.debug(input_event: e) e end
def io
-
(IO)-
def io raise NotImplementedError, "override #{self.class.name}##{__method__}" end
def pid
-
(Integer)-
def pid raise NotImplementedError, "override #{self.class.name}##{__method__}" end
def tag
def tag self.class.name.split('Inputs::').last.underscore end