Browse Source

weed filer.copy: use cached filer grpc connection

another attemp for https://github.com/chrislusf/seaweedfs/issues/915
pull/922/head
Chris Lu 6 years ago
parent
commit
300b39b5af
  1. 12
      weed/command/filer_copy.go

12
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)
}
Loading…
Cancel
Save