Class: Fluent::TailExInput::TailExWatcher

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

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of TailExWatcher.



114
115
116
117
118
# File 'lib/fluent/plugin/in_tail_ex.rb', line 114

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



134
135
136
137
138
139
140
141
# File 'lib/fluent/plugin/in_tail_ex.rb', line 134

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



120
121
122
123
# File 'lib/fluent/plugin/in_tail_ex.rb', line 120

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

#close(loop = nil) ⇒ Object



125
126
127
128
129
130
131
132
# File 'lib/fluent/plugin/in_tail_ex.rb', line 125

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