Skip to content

Commit

Permalink
allow callers of BlockingDial to override grpc.FailOnNonTempDialError…
Browse files Browse the repository at this point in the history
… dial option (#241)
  • Loading branch information
jhump authored Jul 12, 2021
1 parent f1d396c commit de25c89
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions grpcurl.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit de25c89

Please sign in to comment.