You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
999 B

6 years ago
6 years ago
  1. package operation
  2. import (
  3. "google.golang.org/grpc"
  4. "github.com/seaweedfs/seaweedfs/weed/pb"
  5. "github.com/seaweedfs/seaweedfs/weed/pb/master_pb"
  6. "github.com/seaweedfs/seaweedfs/weed/pb/volume_server_pb"
  7. )
  8. func WithVolumeServerClient(streamingMode bool, volumeServer pb.ServerAddress, grpcDialOption grpc.DialOption, fn func(volume_server_pb.VolumeServerClient) error) error {
  9. return pb.WithGrpcClient(streamingMode, func(grpcConnection *grpc.ClientConn) error {
  10. client := volume_server_pb.NewVolumeServerClient(grpcConnection)
  11. return fn(client)
  12. }, volumeServer.ToGrpcAddress(), grpcDialOption)
  13. }
  14. func WithMasterServerClient(streamingMode bool, masterServer pb.ServerAddress, grpcDialOption grpc.DialOption, fn func(masterClient master_pb.SeaweedClient) error) error {
  15. return pb.WithGrpcClient(streamingMode, func(grpcConnection *grpc.ClientConn) error {
  16. client := master_pb.NewSeaweedClient(grpcConnection)
  17. return fn(client)
  18. }, masterServer.ToGrpcAddress(), grpcDialOption)
  19. }