MCPcopy
hub / github.com/segmentio/kafka-go / grabConnTo

Method grabConnTo

transport.go:1051–1073  ·  view source on GitHub ↗
(network, address string)

Source from the content-addressed store, hash-verified

1049}
1050
1051func (g *connGroup) grabConnTo(network, address string) *conn {
1052 g.mutex.Lock()
1053 defer g.mutex.Unlock()
1054
1055 for i := len(g.idleConns) - 1; i >= 0; i-- {
1056 c := g.idleConns[i]
1057
1058 if c.network == network && c.address == address {
1059 copy(g.idleConns[i:], g.idleConns[i+1:])
1060 n := len(g.idleConns) - 1
1061 g.idleConns[n] = nil
1062 g.idleConns = g.idleConns[:n]
1063
1064 if c.timer != nil {
1065 c.timer.Stop()
1066 }
1067
1068 return c
1069 }
1070 }
1071
1072 return nil
1073}
1074
1075func (g *connGroup) grabConn() *conn {
1076 g.mutex.Lock()

Callers 1

grabConnOrConnectMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected