@@ -9,65 +9,33 @@ import (
9
9
context "context"
10
10
11
11
"github.com/cockroachdb/cockroach/pkg/roachpb"
12
+ "github.com/cockroachdb/cockroach/pkg/rpc/nodedialer"
12
13
"github.com/cockroachdb/cockroach/pkg/rpc/rpcbase"
13
14
)
14
15
15
16
// DialMultiRaftClient establishes a DRPC connection if enabled; otherwise,
16
17
// it falls back to gRPC. The established connection is used to create a
17
18
// RPCMultiRaftClient.
18
19
func DialMultiRaftClient (
19
- nd rpcbase. NodeDialer , ctx context.Context , nodeID roachpb.NodeID , class rpcbase.ConnectionClass ,
20
+ nd * nodedialer. Dialer , ctx context.Context , nodeID roachpb.NodeID , class rpcbase.ConnectionClass ,
20
21
) (RPCMultiRaftClient , error ) {
21
- if ! rpcbase .TODODRPC {
22
- conn , err := nd .Dial (ctx , nodeID , class )
23
- if err != nil {
24
- return nil , err
25
- }
26
- return NewGRPCMultiRaftClientAdapter (conn ), nil
27
- }
28
- conn , err := nd .DRPCDial (ctx , nodeID , class )
29
- if err != nil {
30
- return nil , err
31
- }
32
- return NewDRPCMultiRaftClientAdapter (conn ), nil
22
+ return nodedialer .DialRPCClient (nd , ctx , nodeID , class , NewGRPCMultiRaftClientAdapter , NewDRPCMultiRaftClientAdapter )
33
23
}
34
24
35
25
// DialPerReplicaClient establishes a DRPC connection if enabled; otherwise,
36
26
// it falls back to gRPC. The established connection is used to create a
37
27
// RPCPerReplicaClient.
38
28
func DialPerReplicaClient (
39
- nd rpcbase. NodeDialer , ctx context.Context , nodeID roachpb.NodeID , class rpcbase.ConnectionClass ,
29
+ nd * nodedialer. Dialer , ctx context.Context , nodeID roachpb.NodeID , class rpcbase.ConnectionClass ,
40
30
) (RPCPerReplicaClient , error ) {
41
- if ! rpcbase .TODODRPC {
42
- conn , err := nd .Dial (ctx , nodeID , class )
43
- if err != nil {
44
- return nil , err
45
- }
46
- return NewGRPCPerReplicaClientAdapter (conn ), nil
47
- }
48
- conn , err := nd .DRPCDial (ctx , nodeID , class )
49
- if err != nil {
50
- return nil , err
51
- }
52
- return NewDRPCPerReplicaClientAdapter (conn ), nil
31
+ return nodedialer .DialRPCClient (nd , ctx , nodeID , class , NewGRPCPerReplicaClientAdapter , NewDRPCPerReplicaClientAdapter )
53
32
}
54
33
55
34
// DialPerStoreClient establishes a DRPC connection if enabled; otherwise,
56
35
// it falls back to gRPC. The established connection is used to create a
57
36
// RPCPerStoreClient.
58
37
func DialPerStoreClient (
59
- nd rpcbase. NodeDialer , ctx context.Context , nodeID roachpb.NodeID , class rpcbase.ConnectionClass ,
38
+ nd * nodedialer. Dialer , ctx context.Context , nodeID roachpb.NodeID , class rpcbase.ConnectionClass ,
60
39
) (RPCPerStoreClient , error ) {
61
- if ! rpcbase .TODODRPC {
62
- conn , err := nd .Dial (ctx , nodeID , class )
63
- if err != nil {
64
- return nil , err
65
- }
66
- return NewGRPCPerStoreClientAdapter (conn ), nil
67
- }
68
- conn , err := nd .DRPCDial (ctx , nodeID , class )
69
- if err != nil {
70
- return nil , err
71
- }
72
- return NewDRPCPerStoreClientAdapter (conn ), nil
40
+ return nodedialer .DialRPCClient (nd , ctx , nodeID , class , NewGRPCPerStoreClientAdapter , NewDRPCPerStoreClientAdapter )
73
41
}
0 commit comments