示例#1
0
func (s *Server) MonitorPeerState(arg *api.Arguments, stream api.Grpc_MonitorPeerStateServer) error {
	var rf bgp.RouteFamily
	req := NewGrpcRequest(REQ_MONITOR_NEIGHBOR_PEER_STATE, arg.Name, rf, nil)
	s.bgpServerCh <- req

	return handleMultipleResponses(req, func(res *GrpcResponse) error {
		return stream.Send(res.Data.(*api.Peer))
	})
}
示例#2
0
func (s *Server) MonitorPeerState(arg *api.Arguments, stream api.Grpc_MonitorPeerStateServer) error {
	var rf bgp.RouteFamily
	req := NewGrpcRequest(REQ_MONITOR_NEIGHBOR_PEER_STATE, arg.RouterId, rf, nil)
	s.bgpServerCh <- req

	var err error

	for res := range req.ResponseCh {
		if err = res.Err(); err != nil {
			log.Debug(err.Error())
			goto END
		}
		if err = stream.Send(res.Data.(*api.Peer)); err != nil {
			goto END
		}
	}
END:
	req.EndCh <- struct{}{}
	return err
}