func connectionExpiredFunc(v interface{}) bool {
	if v == nil {
		return true
	}
	c, ok := v.(*connection)
	if !ok {
		return true
	}
	switch {
	case atomic.LoadInt32(&c.pool.connected) != connected:
		c.expireReason = event.ReasonPoolClosed
	case c.closed():
		c.expireReason = event.ReasonConnectionErrored
	case c.idleTimeoutExpired():
		c.expireReason = event.ReasonIdle
	case c.pool.stale(c):
		c.expireReason = event.ReasonStale
	default:
		return false
	}
	return true
}
connectionExpiredFunc checks if a given connection is stale and should be removed from the resource pool
package topology
import (
	"context"
	"math"
	"sync"
	"sync/atomic"
	"time"
	"go.mongodb.org/mongo-driver/event"
	"go.mongodb.org/mongo-driver/mongo/address"
	"golang.org/x/sync/semaphore"
)
var ErrPoolConnected = PoolError("attempted to Connect to an already connected pool")
var ErrPoolDisconnected = PoolError("attempted to check out a connection from closed connection pool")
var ErrConnectionClosed = ConnectionError{ConnectionID: "<closed>", message: "connection is closed"}
var ErrWrongPool = PoolError("connection does not belong to this pool")
type PoolError string
var maintainInterval = time.Minute
func (pe PoolError) Error() string { return string(pe) }
type poolConfig struct {
	Address     address.Address
	MinPoolSize uint64
	MaxPoolSize uint64  
	MaxIdleTime time.Duration
	PoolMonitor *event.PoolMonitor
}
type checkOutResult struct {
	c      *connection
	err    error
	reason string
}
type pool struct {
	address    address.Address
	opts       []ConnectionOption
	conns      *resourcePool  
	generation uint64         
	monitor    *event.PoolMonitor
	connected int32  
	nextid    uint64
	opened    map[uint64]*connection  
	sem       *semaphore.Weighted
	sync.Mutex
}