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