2018-10-14 07:12:28 +00:00
|
|
|
package operation
|
|
|
|
|
|
|
|
import (
|
2020-02-26 05:50:12 +00:00
|
|
|
"google.golang.org/grpc"
|
|
|
|
|
2020-03-04 08:39:47 +00:00
|
|
|
"github.com/chrislusf/seaweedfs/weed/pb"
|
2018-10-14 07:12:28 +00:00
|
|
|
"github.com/chrislusf/seaweedfs/weed/pb/master_pb"
|
2018-10-14 07:30:20 +00:00
|
|
|
"github.com/chrislusf/seaweedfs/weed/pb/volume_server_pb"
|
2018-10-14 07:12:28 +00:00
|
|
|
)
|
|
|
|
|
2021-09-13 05:47:52 +00:00
|
|
|
func WithVolumeServerClient(volumeServer pb.ServerAddress, grpcDialOption grpc.DialOption, fn func(volume_server_pb.VolumeServerClient) error) error {
|
2018-10-14 07:12:28 +00:00
|
|
|
|
2020-03-04 08:39:47 +00:00
|
|
|
return pb.WithCachedGrpcClient(func(grpcConnection *grpc.ClientConn) error {
|
2018-12-07 09:25:01 +00:00
|
|
|
client := volume_server_pb.NewVolumeServerClient(grpcConnection)
|
2020-02-26 05:50:12 +00:00
|
|
|
return fn(client)
|
2021-09-13 05:47:52 +00:00
|
|
|
}, volumeServer.ToGrpcAddress(), grpcDialOption)
|
2018-10-14 07:12:28 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2021-09-13 05:47:52 +00:00
|
|
|
func WithMasterServerClient(masterServer pb.ServerAddress, grpcDialOption grpc.DialOption, fn func(masterClient master_pb.SeaweedClient) error) error {
|
2019-01-18 22:14:47 +00:00
|
|
|
|
2020-03-04 08:39:47 +00:00
|
|
|
return pb.WithCachedGrpcClient(func(grpcConnection *grpc.ClientConn) error {
|
2018-12-07 09:25:01 +00:00
|
|
|
client := master_pb.NewSeaweedClient(grpcConnection)
|
2020-02-26 05:50:12 +00:00
|
|
|
return fn(client)
|
2021-09-13 05:47:52 +00:00
|
|
|
}, masterServer.ToGrpcAddress(), grpcDialOption)
|
2020-04-05 07:51:16 +00:00
|
|
|
|
|
|
|
}
|