diff options
| author | Chris Lu <chris.lu@gmail.com> | 2019-04-05 20:31:58 -0700 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2019-04-05 20:31:58 -0700 |
| commit | c789b496d82bb1ff811dd8682c7ebde3d7725a03 (patch) | |
| tree | d3c08adb87674a81fb9a3f9abdf51ec553d2ffc1 /weed/replication/source | |
| parent | 5808caa2f55b1e9c76c5fa50576db895a499892c (diff) | |
| download | seaweedfs-c789b496d82bb1ff811dd8682c7ebde3d7725a03.tar.xz seaweedfs-c789b496d82bb1ff811dd8682c7ebde3d7725a03.zip | |
use cached grpc client
Diffstat (limited to 'weed/replication/source')
| -rw-r--r-- | weed/replication/source/filer_source.go | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/weed/replication/source/filer_source.go b/weed/replication/source/filer_source.go index 3ab6c7261..d7b5ebc4d 100644 --- a/weed/replication/source/filer_source.go +++ b/weed/replication/source/filer_source.go @@ -91,15 +91,11 @@ func (fs *FilerSource) ReadPart(ctx context.Context, part string) (filename stri func (fs *FilerSource) withFilerClient(ctx context.Context, grpcDialOption grpc.DialOption, fn func(filer_pb.SeaweedFilerClient) error) error { - grpcConnection, err := util.GrpcDial(ctx, fs.grpcAddress, grpcDialOption) - if err != nil { - return fmt.Errorf("fail to dial %s: %v", fs.grpcAddress, err) - } - defer grpcConnection.Close() - - client := filer_pb.NewSeaweedFilerClient(grpcConnection) + return util.WithCachedGrpcClient(ctx, func(grpcConnection *grpc.ClientConn) error { + client := filer_pb.NewSeaweedFilerClient(grpcConnection) + return fn(client) + }, fs.grpcAddress, fs.grpcDialOption) - return fn(client) } func volumeId(fileId string) string { |
