How to use tarn - 3 common examples

To help you get started, we’ve selected a few tarn 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 knex / knex / lib / client.js View on Github external
initializePool(config = this.config) {
    if (this.pool) {
      this.logger.warn('The pool has already been initialized');
      return;
    }

    const tarnPoolConfig = {
      ...this.getPoolSettings(config.pool),
    };
    // afterCreate is an internal knex param, tarn.js does not support it
    if (tarnPoolConfig.afterCreate) {
      delete tarnPoolConfig.afterCreate;
    }

    this.pool = new Pool(tarnPoolConfig);
  },
github tediousjs / node-mssql / lib / base.js View on Github external
this._poolDestroy(connection).then(() => {
        if (!this._connecting) {
          debug('pool(%d): not connecting, exiting silently (was close called before connection established?)', IDS.get(this))
          return
        }

        // prepare pool
        this.pool = new tarn.Pool(
          Object.assign({
            create: () => this._poolCreate()
              .then(connection => {
                this._healthy = true
                return connection
              })
              .catch(err => {
                if (this.pool.numUsed() + this.pool.numFree() <= 0) {
                  this._healthy = false
                }
                throw err
              }),
            validate: this._poolValidate.bind(this),
            destroy: this._poolDestroy.bind(this),
            max: 10,
            min: 0,
github AndrewBarba / apns2 / lib / apns.js View on Github external
_createClientPool({ host, port, connections }) {
    return new Pool({
      create: () => new Http2Client(host, port).connect(),
      validate: client => client.ready,
      destroy: client => client.destroy(),
      min: 0,
      max: connections
    })
  }

tarn

Simple and robust resource pool for node.js

MIT
Latest version published 3 years ago

Package Health Score

74 / 100
Full package analysis

Popular tarn functions