2018-10-14 15:12:28 +08:00
|
|
|
package operation
|
|
|
|
|
|
|
|
import (
|
2020-02-26 13:50:12 +08:00
|
|
|
"google.golang.org/grpc"
|
|
|
|
|
2022-07-29 15:17:28 +08:00
|
|
|
"github.com/seaweedfs/seaweedfs/weed/pb"
|
|
|
|
"github.com/seaweedfs/seaweedfs/weed/pb/master_pb"
|
|
|
|
"github.com/seaweedfs/seaweedfs/weed/pb/volume_server_pb"
|
2018-10-14 15:12:28 +08:00
|
|
|
)
|
|
|
|
|
2021-12-26 16:15:03 +08:00
|
|
|
func WithVolumeServerClient(streamingMode bool, volumeServer pb.ServerAddress, grpcDialOption grpc.DialOption, fn func(volume_server_pb.VolumeServerClient) error) error {
|
2018-10-14 15:12:28 +08:00
|
|
|
|
2023-01-20 17:48:12 +08:00
|
|
|
return pb.WithGrpcClient(streamingMode, 0, func(grpcConnection *grpc.ClientConn) error {
|
2018-12-07 17:25:01 +08:00
|
|
|
client := volume_server_pb.NewVolumeServerClient(grpcConnection)
|
2020-02-26 13:50:12 +08:00
|
|
|
return fn(client)
|
2022-08-24 14:18:21 +08:00
|
|
|
}, volumeServer.ToGrpcAddress(), false, grpcDialOption)
|
2018-10-14 15:12:28 +08:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2021-12-26 16:15:03 +08:00
|
|
|
func WithMasterServerClient(streamingMode bool, masterServer pb.ServerAddress, grpcDialOption grpc.DialOption, fn func(masterClient master_pb.SeaweedClient) error) error {
|
2019-01-19 06:14:47 +08:00
|
|
|
|
2023-01-20 17:48:12 +08:00
|
|
|
return pb.WithGrpcClient(streamingMode, 0, func(grpcConnection *grpc.ClientConn) error {
|
2018-12-07 17:25:01 +08:00
|
|
|
client := master_pb.NewSeaweedClient(grpcConnection)
|
2020-02-26 13:50:12 +08:00
|
|
|
return fn(client)
|
2022-08-24 14:18:21 +08:00
|
|
|
}, masterServer.ToGrpcAddress(), false, grpcDialOption)
|
2020-04-05 15:51:16 +08:00
|
|
|
|
|
|
|
}
|