2018-10-14 15:12:28 +08:00
|
|
|
package operation
|
|
|
|
|
|
|
|
import (
|
2020-02-26 13:50:12 +08:00
|
|
|
"google.golang.org/grpc"
|
|
|
|
|
2020-03-04 16:39:47 +08:00
|
|
|
"github.com/chrislusf/seaweedfs/weed/pb"
|
2018-10-14 15:12:28 +08:00
|
|
|
"github.com/chrislusf/seaweedfs/weed/pb/master_pb"
|
2018-10-14 15:30:20 +08:00
|
|
|
"github.com/chrislusf/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
|
|
|
|
2021-12-26 16:15:03 +08:00
|
|
|
return pb.WithGrpcClient(streamingMode, 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)
|
2021-09-13 13:47:52 +08:00
|
|
|
}, volumeServer.ToGrpcAddress(), 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
|
|
|
|
2021-12-26 16:15:03 +08:00
|
|
|
return pb.WithGrpcClient(streamingMode, 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)
|
2021-09-13 13:47:52 +08:00
|
|
|
}, masterServer.ToGrpcAddress(), grpcDialOption)
|
2020-04-05 15:51:16 +08:00
|
|
|
|
|
|
|
}
|