* connnect ensures that a postgres connection is available before continuing * @param {function} callback - function called once connection is confirmed.
(callback)
| 19 | * @param {function} callback - function called once connection is confirmed. |
| 20 | */ |
| 21 | function connect (callback) { |
| 22 | // console.log('L45: PG_CLIENT._connecting:', PG_CLIENT._connecting, |
| 23 | // '| PG_CLIENT._connected:', PG_CLIENT._connected); |
| 24 | if (PG_CLIENT && !PG_CLIENT._connected && !PG_CLIENT._connecting) { |
| 25 | PG_CLIENT.connect(function (error, data) { |
| 26 | utils.log_error(error, data, new Error().stack); |
| 27 | return utils.exec_cb(callback, error, PG_CLIENT); |
| 28 | }); |
| 29 | } else { |
| 30 | return utils.exec_cb(callback, null, PG_CLIENT); |
| 31 | } |
| 32 | } |
| 33 | |
| 34 | /** |
| 35 | * end used in testing to end/close the Postgres connection: |
no outgoing calls
no test coverage detected