Class: RedshiftPG::Connection
- Inherits:
-
Object
- Object
- RedshiftPG::Connection
- 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
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
-
#initialize(config) ⇒ Connection
constructor
A new instance of Connection.
- #pg_connection ⇒ Object
- #reconnect_on_failure(&block) ⇒ Object
Constructor Details
#initialize(config) ⇒ Connection
Returns a new instance of Connection.
13 14 15 16 |
# File 'lib/redshift_pg/connection.rb', line 13 def initialize(config) @config = config @statement_timeout = config['statement_timeout'] end |
Instance Attribute Details
#config ⇒ Object (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_connection ⇒ Object
27 28 29 |
# File 'lib/redshift_pg/connection.rb', line 27 def pg_connection @pg_connection ||= connect! end |
#reconnect_on_failure(&block) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/redshift_pg/connection.rb', line 18 def reconnect_on_failure(&block) begin return yield rescue PG::UnableToSend, PG::ConnectionBad pg_connection.reset return yield end end |