Class: Fluent::Rds_GenlogInput

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

Defined Under Namespace

Classes: TimerWatcher

Instance Method Summary collapse

Constructor Details

#initializeRds_GenlogInput

Returns a new instance of Rds_GenlogInput.



24
25
26
27
# File 'lib/fluent/plugin/in_rds_genlog.rb', line 24

def initialize
  super
  require 'mysql2'
end

Instance Method Details

#configure(conf) ⇒ Object



29
30
31
32
33
34
35
36
# File 'lib/fluent/plugin/in_rds_genlog.rb', line 29

def configure(conf)
  super
  begin
    @client = create_mysql_client
  rescue
    log.error "fluent-plugin-rds-genlog: cannot connect RDS"
  end
end

#shutdownObject



50
51
52
53
54
# File 'lib/fluent/plugin/in_rds_genlog.rb', line 50

def shutdown
  super
  @watcher.terminate
  @watcher.join
end

#startObject



38
39
40
41
42
43
44
45
46
47
48
# File 'lib/fluent/plugin/in_rds_genlog.rb', line 38

def start
  super
  if @backup_table
    @client.query("CREATE TABLE IF NOT EXISTS #{@backup_table} LIKE general_log")
  end

  @loop = Coolio::Loop.new
  timer = TimerWatcher.new(@interval, true, log, &method(:output))
  @loop.attach(timer)
  @watcher = Thread.new(&method(:watch))
end