aboutsummaryrefslogtreecommitdiff
path: root/weed/command/filer_copy.go
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2019-04-05 01:09:06 -0700
committerChris Lu <chris.lu@gmail.com>2019-04-05 01:09:06 -0700
commit300b39b5af583533abf60b763ebcd421ed0fc690 (patch)
tree2e5cbcec53896795523207460557ad9a12fa9e1e /weed/command/filer_copy.go
parent921231268b182620aa004fb49c7e318225b0b3bd (diff)
downloadseaweedfs-300b39b5af583533abf60b763ebcd421ed0fc690.tar.xz
seaweedfs-300b39b5af583533abf60b763ebcd421ed0fc690.zip
weed filer.copy: use cached filer grpc connection
another attemp for https://github.com/chrislusf/seaweedfs/issues/915
Diffstat (limited to 'weed/command/filer_copy.go')
-rw-r--r--weed/command/filer_copy.go12
1 files changed, 4 insertions, 8 deletions
diff --git a/weed/command/filer_copy.go b/weed/command/filer_copy.go
index bd4c7d166..b34ab55d1 100644
--- a/weed/command/filer_copy.go
+++ b/weed/command/filer_copy.go
@@ -343,13 +343,9 @@ func detectMimeType(f *os.File) string {
func withFilerClient(ctx context.Context, filerAddress string, grpcDialOption grpc.DialOption, fn func(filer_pb.SeaweedFilerClient) error) error {
- grpcConnection, err := util.GrpcDial(ctx, filerAddress, grpcDialOption)
- if err != nil {
- return fmt.Errorf("fail to dial %s: %v", filerAddress, err)
- }
- defer grpcConnection.Close()
-
- client := filer_pb.NewSeaweedFilerClient(grpcConnection)
+ return util.WithCachedGrpcClient(ctx, func(clientConn *grpc.ClientConn) error {
+ client := filer_pb.NewSeaweedFilerClient(clientConn)
+ return fn(client)
+ }, filerAddress, grpcDialOption)
- return fn(client)
}