(ctx context.Context, conns []*Conn, reason string)
| 1577 | } |
| 1578 | |
| 1579 | func (p *ConnPool) RetireConns(ctx context.Context, conns []*Conn, reason string) { |
| 1580 | if len(conns) == 0 { |
| 1581 | return |
| 1582 | } |
| 1583 | |
| 1584 | idleConnSet := make(map[*Conn]struct{}) |
| 1585 | toClose := make([]*Conn, 0, len(conns)) |
| 1586 | |
| 1587 | p.connsMu.Lock() |
| 1588 | for _, ic := range p.idleConns { |
| 1589 | idleConnSet[ic] = struct{}{} |
| 1590 | } |
| 1591 | for _, cn := range conns { |
| 1592 | if cn == nil { |
| 1593 | continue |
| 1594 | } |
| 1595 | if _, ok := p.conns[cn.GetID()]; !ok { |
| 1596 | continue |
| 1597 | } |
| 1598 | if _, isIdle := idleConnSet[cn]; isIdle { |
| 1599 | if p.removeConn(cn) { |
| 1600 | toClose = append(toClose, cn) |
| 1601 | } |
| 1602 | continue |
| 1603 | } |
| 1604 | cn.MarkCloseOnPut(reason) |
| 1605 | } |
| 1606 | p.connsMu.Unlock() |
| 1607 | |
| 1608 | if hookManager := p.hookManager.Load(); hookManager != nil { |
| 1609 | for _, cn := range toClose { |
| 1610 | hookManager.ProcessOnRemove(ctx, cn, errors.New(reason)) |
| 1611 | } |
| 1612 | } |
| 1613 | for _, cn := range toClose { |
| 1614 | p.recordConnectionMetrics(ctx, cn, reason, MetricStateIdle) |
| 1615 | _ = p.closeConn(cn) |
| 1616 | } |
| 1617 | p.checkMinIdleConns() |
| 1618 | } |
| 1619 | |
| 1620 | func (p *ConnPool) Filter(fn func(*Conn) bool) error { |
| 1621 | ctx := context.Background() |
nothing calls this directly
no test coverage detected