From 1f9a5cb7e5e8aa90b94847cf787433053ba8324c Mon Sep 17 00:00:00 2001 From: FUJITA Tomonori Date: Tue, 5 Jul 2016 15:09:19 +0900 Subject: move gRPC-related code for REQ_GET_SERVER to grpc_server.go Signed-off-by: FUJITA Tomonori --- server/grpc_server.go | 12 +++++++++++- server/server.go | 14 ++------------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/server/grpc_server.go b/server/grpc_server.go index 1ad4735a..17605f82 100644 --- a/server/grpc_server.go +++ b/server/grpc_server.go @@ -686,7 +686,17 @@ func (s *Server) GetServer(ctx context.Context, arg *api.GetServerRequest) (*api if err != nil { return nil, err } - return d.(*api.GetServerResponse), err + g := d.(*config.Global) + return &api.GetServerResponse{ + Global: &api.Global{ + As: g.Config.As, + RouterId: g.Config.RouterId, + ListenPort: g.Config.Port, + ListenAddresses: g.Config.LocalAddressList, + MplsLabelMin: g.MplsLabelRange.MinLabel, + MplsLabelMax: g.MplsLabelRange.MaxLabel, + }, + }, err } func (s *Server) StartServer(ctx context.Context, arg *api.StartServerRequest) (*api.StartServerResponse, error) { diff --git a/server/server.go b/server/server.go index 0642619b..d5a51c44 100644 --- a/server/server.go +++ b/server/server.go @@ -1528,19 +1528,9 @@ func (server *BgpServer) handleGrpc(grpcReq *GrpcRequest) { switch grpcReq.RequestType { case REQ_GET_SERVER: g := server.bgpConfig.Global - result := &GrpcResponse{ - Data: &api.GetServerResponse{ - Global: &api.Global{ - As: g.Config.As, - RouterId: g.Config.RouterId, - ListenPort: g.Config.Port, - ListenAddresses: g.Config.LocalAddressList, - MplsLabelMin: g.MplsLabelRange.MinLabel, - MplsLabelMax: g.MplsLabelRange.MaxLabel, - }, - }, + grpcReq.ResponseCh <- &GrpcResponse{ + Data: &g, } - grpcReq.ResponseCh <- result close(grpcReq.ResponseCh) case REQ_START_SERVER: err := server.handleModConfig(grpcReq) -- cgit v1.2.3