Updates transport dialopts to use WithBlock() (#1201)

* Updates transport opts to use WithBlock()

* Removes unnecessary withBlock's and adds WithBlock to DialAddress
This commit is contained in:
Dylan Lott 2019-02-01 10:40:35 -07:00 committed by GitHub
parent 5a63c00442
commit c77a647174
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 9 deletions

View File

@ -7,7 +7,6 @@ import (
"context"
"go.uber.org/zap"
"google.golang.org/grpc"
"storj.io/storj/pkg/identity"
"storj.io/storj/pkg/overlay"
@ -85,7 +84,7 @@ func (node *Node) DialPointerDB(destination Peer, apikey string) (pdbclient.Clie
// DialOverlay dials destination and returns an overlay.Client
func (node *Node) DialOverlay(destination Peer) (overlay.Client, error) {
info := destination.Local()
conn, err := node.Transport.DialNode(context.Background(), &info, grpc.WithBlock())
conn, err := node.Transport.DialNode(context.Background(), &info)
if err != nil {
return nil, err
}

View File

@ -106,7 +106,7 @@ func (pool *ConnectionPool) Dial(ctx context.Context, n *pb.Node) (pb.NodesClien
}
conn.dial.Do(func() {
grpc, err := pool.tc.DialNode(ctx, n, grpc.WithBlock())
grpc, err := pool.tc.DialNode(ctx, n)
conn.err = err
if conn.err != nil {
return

View File

@ -68,7 +68,7 @@ func (transport *Transport) DialNode(ctx context.Context, node *pb.Node, opts ..
return nil, Error.Wrap(err)
}
options := append([]grpc.DialOption{dialOpt}, opts...)
options := append([]grpc.DialOption{dialOpt, grpc.WithBlock()}, opts...)
ctx, cf := context.WithTimeout(ctx, timeout)
defer cf()
@ -93,7 +93,7 @@ func (transport *Transport) DialAddress(ctx context.Context, address string, opt
return nil, Error.Wrap(err)
}
options := append([]grpc.DialOption{dialOpt}, opts...)
options := append([]grpc.DialOption{dialOpt, grpc.WithBlock()}, opts...)
conn, err = grpc.Dial(address, options...)
return conn, Error.Wrap(err)
}

View File

@ -9,7 +9,6 @@ import (
"time"
"github.com/stretchr/testify/assert"
"google.golang.org/grpc"
"storj.io/storj/internal/testcontext"
"storj.io/storj/internal/testplanet"
@ -60,7 +59,7 @@ func TestDialNode(t *testing.T) {
tag := fmt.Sprintf("%+v", target)
timedCtx, cancel := context.WithTimeout(ctx, time.Second)
conn, err := client.DialNode(timedCtx, target, grpc.WithBlock())
conn, err := client.DialNode(timedCtx, target)
cancel()
assert.Error(t, err, tag)
assert.Nil(t, conn, tag)
@ -76,7 +75,7 @@ func TestDialNode(t *testing.T) {
Address: planet.StorageNodes[1].Addr(),
},
Type: pb.NodeType_STORAGE,
}, grpc.WithBlock())
})
cancel()
assert.NoError(t, err)
@ -87,7 +86,7 @@ func TestDialNode(t *testing.T) {
{ // DialAddress with valid address
timedCtx, cancel := context.WithTimeout(ctx, time.Second)
conn, err := client.DialAddress(timedCtx, planet.StorageNodes[1].Addr(), grpc.WithBlock())
conn, err := client.DialAddress(timedCtx, planet.StorageNodes[1].Addr())
cancel()
assert.NoError(t, err)