Skip to content

Commit 9a72847

Browse files
committed
update: dial with block
1 parent 337fb18 commit 9a72847

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

utils.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,12 @@ func bytesToUint64(b []byte) (uint64, error) {
3838
}
3939

4040
func dial(address string, dialTimeout time.Duration, dialOptions []grpc.DialOption) (*grpc.ClientConn, error) {
41-
var cc *grpc.ClientConn = nil
4241

43-
err := timeoutFunc(dialTimeout, func() error {
44-
var err error
45-
cc, err = grpc.DialContext(context.Background(), address, dialOptions...)
46-
return err
47-
})
42+
dialOptions = append(dialOptions, grpc.WithBlock())
43+
ctx, cancel := context.WithTimeout(context.Background(), dialTimeout)
44+
defer cancel()
4845

46+
cc, err := grpc.DialContext(ctx, address, dialOptions...)
4947
if err != nil {
5048
return nil, fmt.Errorf("dial %s failed: %v", address, err)
5149
}

0 commit comments

Comments
 (0)