How to use the machinepack-postgresql.releaseConnection function in machinepack-postgresql

To help you get started, we’ve selected a few machinepack-postgresql examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github balderdashy / sails-postgresql / helpers / private / connection / rollback-and-release.js View on Github external
.exec(function rollbackCb() {
    // Only release the connection if the leased flag is false
    if (leased) {
      return cb();
    }

    // Release the connection back into the pool
    PG.releaseConnection({
      connection: connection
    })
    .exec(function releaseCb() {
      return cb();
    });
  });
};
github balderdashy / sails-postgresql / helpers / private / connection / commit-and-release.js View on Github external
.exec(function releaseCb() {
          return cb(err);
        });
      });

      return;
    }

    // Only release the connection if it wasn't leased from outside the
    // adapter.
    if (leased) {
      return cb();
    }

    // Release the connection back into the pool
    PG.releaseConnection({
      connection: connection
    })
    .exec(function releaseCb() {
      return cb();
    });
  });
};
github balderdashy / sails-postgresql / helpers / private / connection / release-connection.js View on Github external
module.exports = function releaseConnection(connection, leased, cb) {
  // If this connection was leased outside of the Adapter, don't release it.
  if (leased) {
    return setImmediate(function ensureAsync() {
      return cb();
    });
  }

  PG.releaseConnection({
    connection: connection
  }).switch({
    error: function error(err) {
      return cb(new Error('There was an error releasing the connection back into the pool.' + err.stack));
    },
    badConnection: function badConnection() {
      return cb(new Error('Bad connection when trying to release an active connection.'));
    },
    success: function success() {
      return cb();
    }
  });
};
github balderdashy / sails-postgresql / helpers / private / connection / begin-transaction.js View on Github external
error: function error(err) {
      // If the connection was leased from outside the adapter, don't release it.
      if (leased) {
        return cb(new Error('There was an error starting a transaction. ' + err.stack));
      }

      PG.releaseConnection({
        connection: connection
      }).exec({
        error: function error(err) {
          return cb(new Error('There was an error releasing the connection back into the pool. ' + err.stack));
        },
        success: function success() {
          return cb(new Error('There was an error starting a transaction. ' + err.stack));
        }
      });
    },
    success: function success() {
github balderdashy / sails-postgresql / helpers / private / connection / commit-and-release.js View on Github external
.exec(function rollbackCb() {
        // Only release the connection if it wasn't leased from outside the
        // adapter.
        if (leased) {
          return cb(err);
        }

        // Release the connection back into the pool
        PG.releaseConnection({
          connection: connection
        })
        .exec(function releaseCb() {
          return cb(err);
        });
      });
github balderdashy / sails-postgresql / test / support / bootstrap.js View on Github external
}).exec(function seedCb(err) {
      if (err) {
        return cb(err);
      }

      PG.releaseConnection({
        connection: report.connection
      }).exec(cb);
    });
  });
github balderdashy / sails-postgresql / test / support / bootstrap.js View on Github external
}).exec(function dropTableCb(err) {
      if (err) {
        return cb(err);
      }

      PG.releaseConnection({
        connection: report.connection
      }).exec(function releaseConnectionCb(err) {
        if (err) {
          return cb(err);
        }

        delete adapter.datastores[_.first(_.keys(adapter.datastores))];
        return cb();
      });
    });
  });