2018-10-14 07:12:28 +00:00
|
|
|
package operation
|
|
|
|
|
|
|
|
import (
|
2020-02-26 05:50:12 +00:00
|
|
|
"google.golang.org/grpc"
|
|
|
|
|
2022-07-29 07:17:28 +00: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 07:12:28 +00:00
|
|
|
)
|
|
|
|
|
2021-12-26 08:15:03 +00:00
|
|
|
func WithVolumeServerClient(streamingMode bool, volumeServer pb.ServerAddress, grpcDialOption grpc.DialOption, fn func(volume_server_pb.VolumeServerClient) error) error {
|
2018-10-14 07:12:28 +00:00
|
|
|
|
2021-12-26 08:15:03 +00:00
|
|
|
return pb.WithGrpcClient(streamingMode, 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-12-26 08:15:03 +00:00
|
|
|
func WithMasterServerClient(streamingMode bool, masterServer pb.ServerAddress, grpcDialOption grpc.DialOption, fn func(masterClient master_pb.SeaweedClient) error) error {
|
2019-01-18 22:14:47 +00:00
|
|
|
|
2021-12-26 08:15:03 +00:00
|
|
|
return pb.WithGrpcClient(streamingMode, 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
|
|
|
|
|
|
|
}
|