147
}
148
149
>
func (c *connectionPoolImpl[C]) getOrCreateClientConn(addr rpcAddress) clientConnection[C] {
connections.go
150
>
if v, ok := c.conns.Load(addr); ok {
151
>
return v.(clientConnection[C]) // nolint:revive // unchecked-type-assertion
152
>
}
153
154
>
grpcConn := c.rpcFactory.CreateHistoryGRPCConnection(string(addr))
connections.go
155
>
cc := clientConnection[C]{
156
>
grpcClient: c.clientCtor(grpcConn),
157
>
grpcConn: grpcConn,
158
>
}
159
>
160
>
if actual, loaded := c.conns.LoadOrStore(addr, cc); loaded {
161
_ = grpcConn.Close()
162
return actual.(clientConnection[C]) // nolint:revive // unchecked-type-assertion
163
}
164
// Lost the race with Close; drop the conn we just cached.
166
if v, ok := c.conns.LoadAndDelete(addr); ok {
167
_ = v.(clientConnection[C]).grpcConn.Close()
168
}
169
}
171
}
172