public void ReturnConnection(ConnectionPoolEntry entry)
        {
            var key = entry.ConnectionString;

            entry.RecordCheckIn();
            avalableConnections[key].Push(entry);
        }
        public ConnectionPoolEntry GetConnection(string connectionString, AuthData authData)
        {
            var key = connectionString;

            ConnectionPoolEntry rv = null;

            avalableConnections.AddOrUpdate(key, k => new ConcurrentStack <ConnectionPoolEntry>(), (k, c) =>
            {
                while (c.TryPop(out var entry))
                {
                    //if we discover that the entry has expired, dispose of it
                    //this typically happens when the entry uses BEARER auth and its token
                    //has expired (or is about to).
                    if (DateTime.Now > entry.ValidTo.Subtract(TimeSpan.FromMinutes(1)))
                    {
                        entry.Connection.Dispose();
                        continue;
                    }

                    rv = entry;
                    break;
                }

                return(c);
            });
 public QueryResult(AdomdDataReader queryResults, bool gzip, bool bufferResults, ConnectionPoolEntry con, ConnectionPool pool, ILogger log)
 {
     this.queryResults  = queryResults;
     this.log           = log;
     this.gzip          = gzip;
     this.bufferResults = bufferResults;
     this.con           = con;
     this.pool          = pool;
 }