Class: RedshiftConnection
- Inherits:
-
Object
- Object
- RedshiftConnection
- Defined in:
- lib/fluent/plugin/out_redshift_v2.rb
Instance Attribute Summary collapse
-
#db_conf ⇒ Object
readonly
Returns the value of attribute db_conf.
Instance Method Summary collapse
- #close ⇒ Object
- #connect_start ⇒ Object
- #exec(sql, &block) ⇒ Object
-
#initialize(db_conf) ⇒ RedshiftConnection
constructor
A new instance of RedshiftConnection.
Constructor Details
#initialize(db_conf) ⇒ RedshiftConnection
Returns a new instance of RedshiftConnection.
366 367 368 369 |
# File 'lib/fluent/plugin/out_redshift_v2.rb', line 366 def initialize(db_conf) @db_conf = db_conf @connection = nil end |
Instance Attribute Details
#db_conf ⇒ Object (readonly)
Returns the value of attribute db_conf.
371 372 373 |
# File 'lib/fluent/plugin/out_redshift_v2.rb', line 371 def db_conf @db_conf end |
Instance Method Details
#close ⇒ Object
391 392 393 394 |
# File 'lib/fluent/plugin/out_redshift_v2.rb', line 391 def close @connection.close rescue nil if @connection @connection = nil end |
#connect_start ⇒ Object
387 388 389 |
# File 'lib/fluent/plugin/out_redshift_v2.rb', line 387 def connect_start @connection = create_redshift_connection end |
#exec(sql, &block) ⇒ Object
373 374 375 376 377 378 379 380 381 382 383 384 385 |
# File 'lib/fluent/plugin/out_redshift_v2.rb', line 373 def exec(sql, &block) conn = @connection conn = create_redshift_connection if conn.nil? if block conn.exec(sql) {|result| block.call(result)} else conn.exec(sql) end rescue PG::Error => e raise RedshiftError.new(e) ensure conn.close if conn && @connection.nil? end |