Class: Fluent::HerokuPostgresOutput
- Inherits:
-
BufferedOutput
- Object
- BufferedOutput
- Fluent::HerokuPostgresOutput
- Includes:
- SetTagKeyMixin, SetTimeKeyMixin
- Defined in:
- lib/fluent/plugin/out_heroku_postgres.rb
Instance Attribute Summary collapse
-
#database ⇒ Object
Returns the value of attribute database.
-
#handler ⇒ Object
Returns the value of attribute handler.
-
#host ⇒ Object
Returns the value of attribute host.
-
#password ⇒ Object
Returns the value of attribute password.
-
#port ⇒ Object
Returns the value of attribute port.
-
#username ⇒ Object
Returns the value of attribute username.
Instance Method Summary collapse
- #client ⇒ Object
-
#configure(conf) ⇒ Object
We don’t currently support mysql’s analogous json format.
- #format(tag, time, record) ⇒ Object
-
#initialize ⇒ HerokuPostgresOutput
constructor
A new instance of HerokuPostgresOutput.
- #shutdown ⇒ Object
- #start ⇒ Object
- #write(chunk) ⇒ Object
Constructor Details
#initialize ⇒ HerokuPostgresOutput
Returns a new instance of HerokuPostgresOutput.
20 21 22 23 |
# File 'lib/fluent/plugin/out_heroku_postgres.rb', line 20 def initialize super require 'pg' end |
Instance Attribute Details
#database ⇒ Object
Returns the value of attribute database.
7 8 9 |
# File 'lib/fluent/plugin/out_heroku_postgres.rb', line 7 def database @database end |
#handler ⇒ Object
Returns the value of attribute handler.
18 19 20 |
# File 'lib/fluent/plugin/out_heroku_postgres.rb', line 18 def handler @handler end |
#host ⇒ Object
Returns the value of attribute host.
7 8 9 |
# File 'lib/fluent/plugin/out_heroku_postgres.rb', line 7 def host @host end |
#password ⇒ Object
Returns the value of attribute password.
7 8 9 |
# File 'lib/fluent/plugin/out_heroku_postgres.rb', line 7 def password @password end |
#port ⇒ Object
Returns the value of attribute port.
7 8 9 |
# File 'lib/fluent/plugin/out_heroku_postgres.rb', line 7 def port @port end |
#username ⇒ Object
Returns the value of attribute username.
7 8 9 |
# File 'lib/fluent/plugin/out_heroku_postgres.rb', line 7 def username @username end |
Instance Method Details
#client ⇒ Object
58 59 60 61 62 63 64 |
# File 'lib/fluent/plugin/out_heroku_postgres.rb', line 58 def client PG::Connection.new({ :host => @host, :port => @port, :user => @username, :password => @password, :dbname => @database }) end |
#configure(conf) ⇒ Object
We don’t currently support mysql’s analogous json format
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/fluent/plugin/out_heroku_postgres.rb', line 26 def configure(conf) super parse_heroku_postgres_url! if @format == 'json' @format_proc = Proc.new{|tag, time, record| record.to_json} else @key_names = @key_names.split(',') @format_proc = Proc.new{|tag, time, record| @key_names.map{|k| record[k]}} end if @columns.nil? and @sql.nil? raise Fluent::ConfigError, "columns or sql MUST be specified, but missing" end if @columns and @sql raise Fluent::ConfigError, "both of columns and sql are specified, but specify one of them" end end |
#format(tag, time, record) ⇒ Object
54 55 56 |
# File 'lib/fluent/plugin/out_heroku_postgres.rb', line 54 def format(tag, time, record) [tag, time, @format_proc.call(tag, time, record)].to_msgpack end |
#shutdown ⇒ Object
50 51 52 |
# File 'lib/fluent/plugin/out_heroku_postgres.rb', line 50 def shutdown super end |
#start ⇒ Object
46 47 48 |
# File 'lib/fluent/plugin/out_heroku_postgres.rb', line 46 def start super end |
#write(chunk) ⇒ Object
66 67 68 69 70 71 72 73 |
# File 'lib/fluent/plugin/out_heroku_postgres.rb', line 66 def write(chunk) handler = self.client handler.prepare("write", @sql) chunk.msgpack_each { |tag, time, data| handler.exec_prepared("write", data) } handler.close end |