Class: RedshiftPG::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/redshift_pg/connection.rb

Constant Summary collapse

SQL_TO_PG_KEY_MAP =
{
  'username' => 'user',
  'database' => 'dbname'
}
PG_INCLUDE_KEYS =
%w(host dbname port user password)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Connection

Returns a new instance of Connection.



13
14
15
# File 'lib/redshift_pg/connection.rb', line 13

def initialize(config)
  @config = config
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



4
5
6
# File 'lib/redshift_pg/connection.rb', line 4

def config
  @config
end

Instance Method Details

#pg_connectionObject



26
27
28
# File 'lib/redshift_pg/connection.rb', line 26

def pg_connection
  @pg_connection ||= connect!
end

#reconnect_on_failure(&block) ⇒ Object



17
18
19
20
21
22
23
24
# File 'lib/redshift_pg/connection.rb', line 17

def reconnect_on_failure(&block)
  begin
    return yield
  rescue PG::UnableToSend, PG::ConnectionBad
    pg_connection.reset
    return yield
  end
end