Class: Fluent::Plugin::PollingPostgresInputPlugin
- Inherits:
-
Input
- Object
- Input
- Fluent::Plugin::PollingPostgresInputPlugin
- 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
Instance Method Summary collapse
-
#shutdown ⇒ Object
Fluentd shutdown method, called to terminate and cleanup plugin.
- #start ⇒ Object
-
#thread_main ⇒ Object
Main polling loop on thread.
Instance Method Details
#shutdown ⇒ Object
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 |
#start ⇒ Object
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_main ⇒ Object
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., error_class: e.class log.error_backtrace end end end |