-
Notifications
You must be signed in to change notification settings - Fork 4.5k
cleanup: replace dial with newclient #8196
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
8ccd175
8151579
7e18f5a
1554a99
d672f29
79f6f35
da31f15
6b913fa
6fb73b9
1dff27f
92ab1a7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,7 +30,7 @@ import ( | |
// NewCredentials returns a credentials which disables transport security. | ||
// | ||
// Note that using this credentials with per-RPC credentials which require | ||
// transport security is incompatible and will cause grpc.Dial() to fail. | ||
// transport security is incompatible and will cause grpc.NewClient() to fail. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did you verify that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. grpc.NewClient() itself doesn't immediately fail when using insecure credentials with per-RPC credentials that require transport security. |
||
func NewCredentials() credentials.TransportCredentials { | ||
return insecureTC{} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -360,7 +360,7 @@ func WithReturnConnectionError() DialOption { | |
// | ||
// Note that using this DialOption with per-RPC credentials (through | ||
// WithCredentialsBundle or WithPerRPCCredentials) which require transport | ||
// security is incompatible and will cause grpc.Dial() to fail. | ||
// security is incompatible and will cause grpc.NewClient() to fail. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did you verify that grpc.NewClient fails? Or does the failure only surface when the channel exits idle state? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. rpc.NewClient() itself doesn't immediately fail when using insecure credentials with per-RPC credentials that require transport security. |
||
// | ||
// Deprecated: use WithTransportCredentials and insecure.NewCredentials() | ||
// instead. Will be supported throughout 1.x. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,7 @@ import ( | |
|
||
"github.com/google/go-cmp/cmp" | ||
"google.golang.org/grpc" | ||
"google.golang.org/grpc/connectivity" | ||
"google.golang.org/grpc/credentials/insecure" | ||
"google.golang.org/grpc/internal" | ||
"google.golang.org/grpc/internal/grpctest" | ||
|
@@ -274,7 +275,6 @@ func (te *test) clientConn() *grpc.ClientConn { | |
} | ||
opts := []grpc.DialOption{ | ||
grpc.WithTransportCredentials(insecure.NewCredentials()), | ||
grpc.WithBlock(), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you are removing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for pointing that out — you're absolutely right. Removing |
||
grpc.WithUserAgent("test/0.0.1"), | ||
} | ||
if te.compress == "gzip" { | ||
|
@@ -288,10 +288,14 @@ func (te *test) clientConn() *grpc.ClientConn { | |
} | ||
|
||
var err error | ||
te.cc, err = grpc.Dial(te.srvAddr, opts...) | ||
te.cc, err = grpc.NewClient(te.srvAddr, opts...) | ||
if err != nil { | ||
te.t.Fatalf("Dial(%q) = %v", te.srvAddr, err) | ||
te.t.Fatalf("grpc.NewClient() failed(%q) = %v", te.srvAddr, err) | ||
} | ||
te.cc.Connect() | ||
ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout) | ||
defer cancel() | ||
testutils.AwaitState(ctx, te.t, te.cc, connectivity.Ready) | ||
return te.cc | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please only change
log
tot
, the error message is fine.