From de25c898228e36e8539862ed08de69598e64cb76 Mon Sep 17 00:00:00 2001 From: Joshua Humphries Date: Mon, 12 Jul 2021 15:27:33 -0400 Subject: [PATCH] allow callers of BlockingDial to override grpc.FailOnNonTempDialError dial option (#241) --- grpcurl.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/grpcurl.go b/grpcurl.go index 167cab0..e627988 100644 --- a/grpcurl.go +++ b/grpcurl.go @@ -635,11 +635,13 @@ func BlockingDial(ctx context.Context, network, address string, creds credential // know when we're done. So we run it in a goroutine and then use result // channel to either get the connection or fail-fast. go func() { - opts = append(opts, - grpc.WithBlock(), - grpc.FailOnNonTempDialError(true), - grpc.WithContextDialer(dialer), - ) + // We put grpc.FailOnNonTempDialError *before* the explicitly provided + // options so that it could be overridden. + opts = append([]grpc.DialOption{grpc.FailOnNonTempDialError(true)}, opts...) + // But we don't want caller to be able to override these two, so we put + // them *after* the explicitly provided options. + opts = append(opts, grpc.WithBlock(), grpc.WithContextDialer(dialer)) + if creds == nil { opts = append(opts, grpc.WithInsecure()) } else {