Skip to content

Commit

Permalink
Use passthrough resolver when bufnet is used
Browse files Browse the repository at this point in the history
  • Loading branch information
ash2k committed May 29, 2024
1 parent 1e8c7ca commit 255855e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func benchmark(b *testing.B, cOpt []grpc.DialOption, sOpt []grpc.ServerOption) {
ctx := context.Background()
dial := func(context.Context, string) (net.Conn, error) { return l.Dial() }
conn, err := grpc.NewClient(
"bufnet",
"passthrough:bufnet",
append([]grpc.DialOption{
grpc.WithContextDialer(dial),
grpc.WithTransportCredentials(insecure.NewCredentials()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,16 @@ func newGrpcTest(t testing.TB, listener net.Listener, cOpt []grpc.DialOption, sO

cOpt = append(cOpt, grpc.WithTransportCredentials(insecure.NewCredentials()))

dialAddr := listener.Addr().String()

if l, ok := listener.(interface{ Dial() (net.Conn, error) }); ok {
dial := func(context.Context, string) (net.Conn, error) { return l.Dial() }
cOpt = append(cOpt, grpc.WithContextDialer(dial))
dialAddr = "passthrough:" + dialAddr
}

conn, err := grpc.NewClient(
listener.Addr().String(),
dialAddr,
cOpt...,
)
require.NoError(t, err)
Expand Down

0 comments on commit 255855e

Please sign in to comment.