diff options
author | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2015-12-01 14:57:51 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-12-02 08:53:04 +0900 |
commit | ff26d4e93bf728b4fb312a2f66b1becbd2675c9f (patch) | |
tree | c0128bcba14072fbd41885ff437252d4d008a23d /server/grpc_server.go | |
parent | 3dfb941b336dc72bcd6fcadfd7b55f7c67ffcc4e (diff) |
api/server: refine GetRib API
Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Diffstat (limited to 'server/grpc_server.go')
-rw-r--r-- | server/grpc_server.go | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/server/grpc_server.go b/server/grpc_server.go index 68d0e72b..07ff4e94 100644 --- a/server/grpc_server.go +++ b/server/grpc_server.go @@ -121,9 +121,9 @@ func (s *Server) GetNeighbors(_ *api.Arguments, stream api.GobgpApi_GetNeighbors }) } -func (s *Server) GetRib(arg *api.Arguments, stream api.GobgpApi_GetRibServer) error { +func (s *Server) GetRib(ctx context.Context, arg *api.Table) (*api.Table, error) { var reqType int - switch arg.Resource { + switch arg.Type { case api.Resource_LOCAL: reqType = REQ_LOCAL_RIB case api.Resource_GLOBAL: @@ -135,15 +135,13 @@ func (s *Server) GetRib(arg *api.Arguments, stream api.GobgpApi_GetRibServer) er case api.Resource_VRF: reqType = REQ_VRF default: - return fmt.Errorf("unsupported resource type: %v", arg.Resource) + return nil, fmt.Errorf("unsupported resource type: %v", arg.Type) } - - req := NewGrpcRequest(reqType, arg.Name, bgp.RouteFamily(arg.Rf), nil) - s.bgpServerCh <- req - - return handleMultipleResponses(req, func(res *GrpcResponse) error { - return stream.Send(res.Data.(*api.Destination)) - }) + d, err := s.get(reqType, arg) + if err != nil { + return nil, err + } + return d.(*api.Table), nil } func (s *Server) MonitorBestChanged(arg *api.Arguments, stream api.GobgpApi_MonitorBestChangedServer) error { |