Class: Fluent::PgJsonOutput

Inherits:
BufferedOutput
  • Object
show all
Defined in:
lib/fluent/plugin/out_pgjson.rb

Instance Method Summary collapse

Constructor Details

#initializePgJsonOutput

Returns a new instance of PgJsonOutput.



17
18
19
20
# File 'lib/fluent/plugin/out_pgjson.rb', line 17

def initialize
  super
  require 'pg'
end

Instance Method Details

#configure(conf) ⇒ Object



22
23
24
25
# File 'lib/fluent/plugin/out_pgjson.rb', line 22

def configure(conf)
  super
  @stmt_name = 'insert'
end

#format(tag, time, record) ⇒ Object



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

def format(tag, time, record)
  [tag, time, record].to_msgpack
end

#shutdownObject



32
33
34
35
36
37
# File 'lib/fluent/plugin/out_pgjson.rb', line 32

def shutdown
  super
  if !@conn.nil? and !@conn.finished?
    @conn.close()
  end
end

#startObject



27
28
29
30
# File 'lib/fluent/plugin/out_pgjson.rb', line 27

def start
  super
  init_connection
end

#write(chunk) ⇒ Object



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

def write(chunk)
  begin
    sql = build_sql(chunk)
    @conn.exec(sql)
  rescue
    #TODO
    raise
  end
end