Class: Fluent::SystemdInput::PosWriter

Inherits:
Object
  • Object
show all
Defined in:
lib/fluent/plugin/systemd/pos_writer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pos_file) ⇒ PosWriter

Returns a new instance of PosWriter.



6
7
8
9
# File 'lib/fluent/plugin/systemd/pos_writer.rb', line 6

def initialize(pos_file)
  @path = pos_file
  setup
end

Instance Attribute Details

#cursorObject (readonly)

Returns the value of attribute cursor.



11
12
13
# File 'lib/fluent/plugin/systemd/pos_writer.rb', line 11

def cursor
  @cursor
end

#pathObject (readonly)

Returns the value of attribute path.



11
12
13
# File 'lib/fluent/plugin/systemd/pos_writer.rb', line 11

def path
  @path
end

Instance Method Details

#shutdownObject



19
20
21
22
23
24
# File 'lib/fluent/plugin/systemd/pos_writer.rb', line 19

def shutdown
  return unless path
  @running = false
  thread.join
  write_pos
end

#startObject



13
14
15
16
17
# File 'lib/fluent/plugin/systemd/pos_writer.rb', line 13

def start
  return unless path
  @running = true
  @thread = Thread.new(&method(:work))
end

#update(c) ⇒ Object



26
27
28
29
# File 'lib/fluent/plugin/systemd/pos_writer.rb', line 26

def update(c)
  return unless path
  lock.synchronize { @cursor = c }
end