Class: Fluent::Plugin::PollingPostgresInputPlugin

Inherits:
Input
  • Object
show all
Defined in:
lib/fluent/plugin/polling_pg_input_plugin.rb

Overview

PollingPostgresInputPlugin is intended to be used as an base class for input plugins that poll postgres.

Child classes should implement the ‘on_poll` method

Direct Known Subclasses

PgStatActivityInput, PgStatStatementsInput

Instance Method Summary collapse

Instance Method Details

#shutdownObject

Fluentd shutdown method, called to terminate and cleanup plugin



45
46
47
48
49
50
51
# File 'lib/fluent/plugin/polling_pg_input_plugin.rb', line 45

def shutdown
  @stop_flag = true

  # Interrupt thread and wait for it to finish
  Thread.new { @thread.run } if @thread
  @thread.join
end

#startObject



39
40
41
42
# File 'lib/fluent/plugin/polling_pg_input_plugin.rb', line 39

def start
  @stop_flag = false
  @thread = Thread.new(&method(:thread_main))
end

#thread_mainObject

Main polling loop on thread



54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/fluent/plugin/polling_pg_input_plugin.rb', line 54

def thread_main
  until @stop_flag
    sleep @interval
    break if @stop_flag

    begin
      on_poll
    rescue StandardError => e
      log.error 'unexpected error', error: e.message, error_class: e.class
      log.error_backtrace
    end
  end
end