Class: Fluent::Compat::SocketUtil::BaseInput

Inherits:
Input
  • Object
show all
Defined in:
lib/fluent/compat/socket_util.rb

Instance Method Summary collapse

Constructor Details

#initializeBaseInput

Returns a new instance of BaseInput.



97
98
99
100
# File 'lib/fluent/compat/socket_util.rb', line 97

def initialize
  super
  require 'fluent/parser'
end

Instance Method Details

#configure(conf) ⇒ Object



114
115
116
117
118
119
# File 'lib/fluent/compat/socket_util.rb', line 114

def configure(conf)
  super

  @parser = Plugin.new_parser(@format)
  @parser.configure(conf)
end

#runObject



139
140
141
142
143
144
# File 'lib/fluent/compat/socket_util.rb', line 139

def run
  @loop.run(@blocking_timeout)
rescue => e
  log.error "unexpected error", error: e
  log.error_backtrace
end

#shutdownObject



130
131
132
133
134
135
136
137
# File 'lib/fluent/compat/socket_util.rb', line 130

def shutdown
  @loop.watchers.each { |w| w.detach }
  @loop.stop if @loop.instance_variable_get("@running")
  @handler.close
  @thread.join

  super
end

#startObject



121
122
123
124
125
126
127
128
# File 'lib/fluent/compat/socket_util.rb', line 121

def start
  super

  @loop = Coolio::Loop.new
  @handler = listen(method(:on_message))
  @loop.attach(@handler)
  @thread = Thread.new(&method(:run))
end