func connectionExpiredFunc(v interface{}) bool {
	if v == nil {
		return true
	}

	c, ok := v.(*connection)
	if !ok {
		return true
	}
	var reason string
	disconnected := atomic.LoadInt32(&c.pool.connected) != connected
	if disconnected {
		reason = event.ReasonPoolClosed
	}

	idle := c.expired()
	if !disconnected && idle {
		reason = event.ReasonIdle
	}

	stale := c.pool.stale(c)
	if !disconnected && !idle && stale {
		reason = event.ReasonStale
	}

	res := disconnected || stale || idle
	if res && c.pool.monitor != nil {
		c.pool.monitor.Event(&event.PoolEvent{
			Type:         event.ConnectionClosed,
			Address:      c.pool.address.String(),
			ConnectionID: c.poolID,
			Reason:       reason,
		})
	}

	return res
}
// connectionExpiredFunc checks if a given connection is stale and should be removed from the resource pool
connectionExpiredFunc checks if a given connection is stale and should be removed from the resource pool
// connectionExpiredFunc checks if a given connection is stale and should be removed from the resource pool
func connectionExpiredFunc(v interface{}) bool {
	if v == nil {
		return true
	}
	c, ok := v.(*connection)
	if !ok {
		return true
	}
	var reason string
	disconnected := atomic.LoadInt32(&c.pool.connected) != connected
	if disconnected {
		reason = event.ReasonPoolClosed
	}
	idle := c.expired()
	if !disconnected && idle {
		reason = event.ReasonIdle
	}
	stale := c.pool.stale(c)
	if !disconnected && !idle && stale {
		reason = event.ReasonStale
	}
	res := disconnected || stale || idle
	if res && c.pool.monitor != nil {
		c.pool.monitor.Event(&event.PoolEvent{
			Type:         event.ConnectionClosed,
			Address:      c.pool.address.String(),
			ConnectionID: c.poolID,
			Reason:       reason,
		})
	}
	return res
}
func connectionExpiredFunc ( v interface { } ) bool { if v == nil { return true } c , ok := v . ( * connection ) if ! ok { return true } var reason string disconnected := atomic . LoadInt32 ( & c . pool . connected ) != connected if disconnected { reason = event . ReasonPoolClosed } idle := c . expired ( ) if ! disconnected && idle { reason = event . ReasonIdle } stale := c . pool . stale ( c ) if ! disconnected && ! idle && stale { reason = event . ReasonStale } res := disconnected || stale || idle if res && c . pool . monitor != nil { c . pool . monitor . Event ( & event . PoolEvent { Type : event . ConnectionClosed , Address : c . pool . address . String ( ) , ConnectionID : c . poolID , Reason : reason , } ) } return res }
connectionExpiredFunc checks if a given connection is stale and should be removed from the resource pool
connectionExpiredFunc checks if a given connection is stale and should be removed from the resource pool