weed filer.copy: use cached filer grpc connection
another attemp for https://github.com/chrislusf/seaweedfs/issues/915
This commit is contained in:
@@ -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 {
|
func withFilerClient(ctx context.Context, filerAddress string, grpcDialOption grpc.DialOption, fn func(filer_pb.SeaweedFilerClient) error) error {
|
||||||
|
|
||||||
grpcConnection, err := util.GrpcDial(ctx, filerAddress, grpcDialOption)
|
return util.WithCachedGrpcClient(ctx, func(clientConn *grpc.ClientConn) error {
|
||||||
if err != nil {
|
client := filer_pb.NewSeaweedFilerClient(clientConn)
|
||||||
return fmt.Errorf("fail to dial %s: %v", filerAddress, err)
|
return fn(client)
|
||||||
}
|
}, filerAddress, grpcDialOption)
|
||||||
defer grpcConnection.Close()
|
|
||||||
|
|
||||||
client := filer_pb.NewSeaweedFilerClient(grpcConnection)
|
|
||||||
|
|
||||||
return fn(client)
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user