code: function(pool) {
      if (idleConnections.isEmpty()) {
        return Promise.reject(null);
      }
      const conn = idleConnections.shift();
      activeConnections[conn.threadId] = conn;
      if (
        opts.minDelayValidation <= 0 ||
        Date.now() - conn.lastUse > opts.minDelayValidation
      ) {
        return pingPromise(conn)
          .then(() => {
            return Promise.resolve(conn);
          })
          .catch(err => {
            delete activeConnections[conn.threadId];
            pool.emit('remove-conn');
            return getIdleValidConnection(pool);
          });
      } else {
        //just check connection state
        if (conn.isValid()) {
          return Promise.resolve(conn);
        } else {
          delete activeConnections[conn.threadId];
          pool.emit('remove-conn');
          return getIdleValidConnection(pool);
        }
      }
    }
docs: Return an idle Connection.
  If connection has not been used for some time ( minDelayValidation), validate connection status.
  
  @param pool pool
  @returns {Promise<Connection|null>)} connection of null of no valid idle connection.