@@ -27,6 +27,7 @@ import (
27
27
"github.com/cockroachdb/cockroach/pkg/util/stop"
28
28
"github.com/cockroachdb/errors"
29
29
"google.golang.org/grpc"
30
+ "storj.io/drpc"
30
31
)
31
32
32
33
// serverID is a type that is either a `roachpb.NodeID`
@@ -51,6 +52,11 @@ type ServerIterator interface {
51
52
dialNode (
52
53
ctx context.Context , serverID serverID ,
53
54
) (* grpc.ClientConn , error )
55
+ // drpcDialNode provides a DRPC connection to the node or SQL instance
56
+ // identified by serverID.
57
+ drpcDialNode (
58
+ ctx context.Context , serverID serverID ,
59
+ ) (drpc.Conn , error )
54
60
// getAllNodes returns a map of all nodes in the cluster
55
61
// or instances in the tenant with their liveness status.
56
62
getAllNodes (
@@ -89,6 +95,12 @@ func (d *nodeDialer) Dial(
89
95
return d .si .dialNode (ctx , serverID (nodeID ))
90
96
}
91
97
98
+ func (d * nodeDialer ) DRPCDial (
99
+ ctx context.Context , nodeID roachpb.NodeID , _ rpcbase.ConnectionClass ,
100
+ ) (drpc.Conn , error ) {
101
+ return d .si .drpcDialNode (ctx , serverID (nodeID ))
102
+ }
103
+
92
104
type tenantFanoutClient struct {
93
105
sqlServer * SQLServer
94
106
rpcCtx * rpc.Context
@@ -157,6 +169,17 @@ func (t *tenantFanoutClient) dialNode(
157
169
return t .rpcCtx .GRPCDialPod (instance .InstanceRPCAddr , id , instance .Locality , rpcbase .DefaultClass ).Connect (ctx )
158
170
}
159
171
172
+ func (t * tenantFanoutClient ) drpcDialNode (
173
+ ctx context.Context , serverID serverID ,
174
+ ) (drpc.Conn , error ) {
175
+ id := base .SQLInstanceID (serverID )
176
+ instance , err := t .sqlServer .sqlInstanceReader .GetInstance (ctx , id )
177
+ if err != nil {
178
+ return nil , err
179
+ }
180
+ return t .rpcCtx .DRPCDialPod (instance .InstanceRPCAddr , id , instance .Locality , rpcbase .DefaultClass ).Connect (ctx )
181
+ }
182
+
160
183
func (t * tenantFanoutClient ) getAllNodes (
161
184
ctx context.Context ,
162
185
) (map [serverID ]livenesspb.NodeLivenessStatus , error ) {
@@ -238,6 +261,15 @@ func (k kvFanoutClient) dialNode(ctx context.Context, serverID serverID) (*grpc.
238
261
return k .rpcCtx .GRPCDialNode (addr .String (), id , locality , rpcbase .DefaultClass ).Connect (ctx )
239
262
}
240
263
264
+ func (k kvFanoutClient ) drpcDialNode (ctx context.Context , serverID serverID ) (drpc.Conn , error ) {
265
+ id := roachpb .NodeID (serverID )
266
+ addr , locality , err := k .gossip .GetNodeIDAddress (id )
267
+ if err != nil {
268
+ return nil , err
269
+ }
270
+ return k .rpcCtx .DRPCDialNode (addr .String (), id , locality , rpcbase .DefaultClass ).Connect (ctx )
271
+ }
272
+
241
273
func (k kvFanoutClient ) listNodes (ctx context.Context ) (* serverpb.NodesResponse , error ) {
242
274
ctx = authserver .ForwardSQLIdentityThroughRPCCalls (ctx )
243
275
ctx = k .ambientCtx .AnnotateCtx (ctx )
0 commit comments