Class: Fluent::PgJsonOutput
- Inherits:
-
BufferedOutput
- Object
- BufferedOutput
- Fluent::PgJsonOutput
- Defined in:
- lib/fluent/plugin/out_pgjson.rb
Instance Method Summary collapse
- #configure(conf) ⇒ Object
- #format(tag, time, record) ⇒ Object
-
#initialize ⇒ PgJsonOutput
constructor
A new instance of PgJsonOutput.
- #shutdown ⇒ Object
- #start ⇒ Object
- #write(chunk) ⇒ Object
Constructor Details
#initialize ⇒ PgJsonOutput
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 |
#shutdown ⇒ Object
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 |
#start ⇒ Object
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 |