@@ -19,13 +19,13 @@ var (
1919// An GrpcTransporter is a default transport layer used to communicate between
2020// multiple servers.
2121type GrpcTransporter struct {
22- grpcDialOption grpc.DialOption
22+ grpcDialOptions [] grpc.DialOption
2323}
2424
2525// Creates a new HTTP transporter with the given path prefix.
26- func NewGrpcTransporter (grpcDialOption grpc.DialOption ) * GrpcTransporter {
26+ func NewGrpcTransporter (grpcDialOptions ... grpc.DialOption ) * GrpcTransporter {
2727 t := & GrpcTransporter {
28- grpcDialOption : grpcDialOption ,
28+ grpcDialOptions : grpcDialOptions ,
2929 }
3030 return t
3131}
@@ -49,7 +49,7 @@ func NewGrpcServer(server Server) *GrpcServer {
4949// Sends an AppendEntries RPC to a peer.
5050func (t * GrpcTransporter ) SendAppendEntriesRequest (server Server , peer * Peer , req * AppendEntriesRequest ) (ret * AppendEntriesResponse ) {
5151
52- err := withRaftServerClient (peer .ConnectionString , t .grpcDialOption , func (client protobuf.RaftClient ) error {
52+ err := withRaftServerClient (peer .ConnectionString , t .grpcDialOptions , func (client protobuf.RaftClient ) error {
5353 ctx , cancel := context2 .WithTimeout (context2 .Background (), time .Duration (5 * time .Second ))
5454 defer cancel ()
5555
@@ -83,7 +83,7 @@ func (t *GrpcTransporter) SendAppendEntriesRequest(server Server, peer *Peer, re
8383// Sends a RequestVote RPC to a peer.
8484func (t * GrpcTransporter ) SendVoteRequest (server Server , peer * Peer , req * RequestVoteRequest ) (ret * RequestVoteResponse ) {
8585
86- err := withRaftServerClient (peer .ConnectionString , t .grpcDialOption , func (client protobuf.RaftClient ) error {
86+ err := withRaftServerClient (peer .ConnectionString , t .grpcDialOptions , func (client protobuf.RaftClient ) error {
8787 ctx , cancel := context2 .WithTimeout (context2 .Background (), time .Duration (5 * time .Second ))
8888 defer cancel ()
8989
@@ -117,7 +117,7 @@ func (t *GrpcTransporter) SendVoteRequest(server Server, peer *Peer, req *Reques
117117// Sends a SnapshotRequest RPC to a peer.
118118func (t * GrpcTransporter ) SendSnapshotRequest (server Server , peer * Peer , req * SnapshotRequest ) (ret * SnapshotResponse ) {
119119
120- err := withRaftServerClient (peer .ConnectionString , t .grpcDialOption , func (client protobuf.RaftClient ) error {
120+ err := withRaftServerClient (peer .ConnectionString , t .grpcDialOptions , func (client protobuf.RaftClient ) error {
121121 ctx , cancel := context2 .WithTimeout (context2 .Background (), time .Duration (5 * time .Second ))
122122 defer cancel ()
123123
@@ -149,7 +149,7 @@ func (t *GrpcTransporter) SendSnapshotRequest(server Server, peer *Peer, req *Sn
149149// Sends a SnapshotRequest RPC to a peer.
150150func (t * GrpcTransporter ) SendSnapshotRecoveryRequest (server Server , peer * Peer , req * SnapshotRecoveryRequest ) (ret * SnapshotRecoveryResponse ) {
151151
152- err := withRaftServerClient (peer .ConnectionString , t .grpcDialOption , func (client protobuf.RaftClient ) error {
152+ err := withRaftServerClient (peer .ConnectionString , t .grpcDialOptions , func (client protobuf.RaftClient ) error {
153153 ctx , cancel := context2 .WithTimeout (context2 .Background (), time .Duration (5 * time .Second ))
154154 defer cancel ()
155155
@@ -285,12 +285,12 @@ func (t *GrpcServer) OnSendSnapshotRecoveryRequest(ctx context2.Context, pbReq *
285285 }, nil
286286}
287287
288- func withRaftServerClient (raftServer string , grpcDialOption grpc.DialOption , fn func (protobuf.RaftClient ) error ) error {
288+ func withRaftServerClient (raftServer string , grpcDialOptions [] grpc.DialOption , fn func (protobuf.RaftClient ) error ) error {
289289
290290 return withCachedGrpcClient (func (grpcConnection * grpc.ClientConn ) error {
291291 client := protobuf .NewRaftClient (grpcConnection )
292292 return fn (client )
293- }, raftServer , grpcDialOption )
293+ }, raftServer , grpcDialOptions ... )
294294
295295}
296296
0 commit comments