Class: Fluent::TailExAsisInput::TailExAsisWatcher

Inherits:
TailWatcher
  • Object
show all
Defined in:
lib/fluent/plugin/in_tail_ex_asis.rb

Instance Method Summary collapse

Constructor Details

#initialize(path, rotate_wait, pe, &receive_lines) ⇒ TailExAsisWatcher

Returns a new instance of TailExAsisWatcher.



131
132
133
134
135
# File 'lib/fluent/plugin/in_tail_ex_asis.rb', line 131

def initialize(path, rotate_wait, pe, &receive_lines)
  @parent_receive_lines = receive_lines
  super(path, rotate_wait, pe, &method(:_receive_lines))
  @close_trigger = TimerWatcher.new(rotate_wait * 2, false, &method(:_close))
end

Instance Method Details

#_closeObject



151
152
153
154
155
156
157
158
# File 'lib/fluent/plugin/in_tail_ex_asis.rb', line 151

def _close
  @close_trigger.detach if @close_trigger.attached?
  self.class.superclass.instance_method(:close).bind(self).call

  @io_handler.on_notify
  @io_handler.close
  $log.info "stop following of #{@path}"
end

#_receive_lines(lines) ⇒ Object



137
138
139
140
# File 'lib/fluent/plugin/in_tail_ex_asis.rb', line 137

def _receive_lines(lines)
  tag = @path.tr('/', '.').gsub(/\.+/, '.').gsub(/^\./, '')
  @parent_receive_lines.call(lines, tag)
end

#close(loop = nil) ⇒ Object



142
143
144
145
146
147
148
149
# File 'lib/fluent/plugin/in_tail_ex_asis.rb', line 142

def close(loop=nil)
  detach                  # detach first to avoid timer conflict
  if loop
    @close_trigger.attach(loop)
  else
    _close
  end
end