Skip to content

Commit 075c4bc

Browse files
craig[bot]cthumuluru-crdb
andcommitted
Merge #147313
147313: rpc: use rpcConn as stream pool generic constraint r=cthumuluru-crdb a=cthumuluru-crdb Previously, stream pools used `any` as their generic type constraint. This commit updates the constraint to `rpcConn`, which is a more suitable and type-safe choice for RPC connections. Fixes: none Epic: CRDB-48923 Release note: none Co-authored-by: Chandra Thumuluru <[email protected]>
2 parents 8d598cb + 4a4d295 commit 075c4bc

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

pkg/rpc/stream_pool.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ type streamClient[Req, Resp any] interface {
2929

3030
// streamConstructor creates a new gRPC stream client over the provided client
3131
// connection, using the provided call options.
32-
type streamConstructor[Req, Resp, Conn any] func(
32+
type streamConstructor[Req, Resp any, Conn rpcConn] func(
3333
context.Context, Conn,
3434
) (streamClient[Req, Resp], error)
3535

@@ -67,7 +67,7 @@ const defaultPooledStreamIdleTimeout = 10 * time.Second
6767
//
6868
// A pooledStream must only be returned to the pool for reuse after a successful
6969
// Send call. If the Send call fails, the pooledStream must not be reused.
70-
type pooledStream[Req, Resp any, Conn comparable] struct {
70+
type pooledStream[Req, Resp any, Conn rpcConn] struct {
7171
pool *streamPool[Req, Resp, Conn]
7272
stream streamClient[Req, Resp]
7373
streamCtx context.Context
@@ -77,7 +77,7 @@ type pooledStream[Req, Resp any, Conn comparable] struct {
7777
respC chan result[Resp]
7878
}
7979

80-
func newPooledStream[Req, Resp any, Conn comparable](
80+
func newPooledStream[Req, Resp any, Conn rpcConn](
8181
pool *streamPool[Req, Resp, Conn],
8282
stream streamClient[Req, Resp],
8383
streamCtx context.Context,
@@ -190,7 +190,7 @@ func (s *pooledStream[Req, Resp, Conn]) Send(ctx context.Context, req Req) (Resp
190190
// manner that mimics unary RPC invocation. Pooling these streams allows for
191191
// reuse of gRPC resources across calls, as opposed to native unary RPCs, which
192192
// create a new stream and throw it away for each request (see grpc.invoke).
193-
type streamPool[Req, Resp any, Conn comparable] struct {
193+
type streamPool[Req, Resp any, Conn rpcConn] struct {
194194
stopper *stop.Stopper
195195
idleTimeout time.Duration
196196
newStream streamConstructor[Req, Resp, Conn]
@@ -206,7 +206,7 @@ type streamPool[Req, Resp any, Conn comparable] struct {
206206
}
207207
}
208208

209-
func makeStreamPool[Req, Resp any, Conn comparable](
209+
func makeStreamPool[Req, Resp any, Conn rpcConn](
210210
stopper *stop.Stopper, newStream streamConstructor[Req, Resp, Conn],
211211
) streamPool[Req, Resp, Conn] {
212212
return streamPool[Req, Resp, Conn]{

0 commit comments

Comments
 (0)