mirror of
https://github.com/osrg/gobgp.git
synced 2024-05-11 05:55:10 +00:00
move gRPC-related code for REQ_GET_SERVER to grpc_server.go
Signed-off-by: FUJITA Tomonori <[email protected]>
This commit is contained in:
@@ -1706,11 +1706,7 @@ func (s *Server) ReplacePolicyAssignment(ctx context.Context, arg *api.ReplacePo
|
||||
}
|
||||
|
||||
func (s *Server) GetServer(ctx context.Context, arg *api.GetServerRequest) (*api.GetServerResponse, error) {
|
||||
d, err := s.get(REQ_GET_SERVER, arg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
g := d.(*config.Global)
|
||||
g := s.bgpServer.GetServer()
|
||||
return &api.GetServerResponse{
|
||||
Global: &api.Global{
|
||||
As: g.Config.As,
|
||||
@@ -1720,7 +1716,7 @@ func (s *Server) GetServer(ctx context.Context, arg *api.GetServerRequest) (*api
|
||||
MplsLabelMin: g.MplsLabelRange.MinLabel,
|
||||
MplsLabelMax: g.MplsLabelRange.MaxLabel,
|
||||
},
|
||||
}, err
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *Server) StartServer(ctx context.Context, arg *api.StartServerRequest) (*api.StartServerResponse, error) {
|
||||
|
||||
+13
-6
@@ -1361,12 +1361,6 @@ func (server *BgpServer) handleGrpc(grpcReq *GrpcRequest) {
|
||||
var err error
|
||||
|
||||
switch grpcReq.RequestType {
|
||||
case REQ_GET_SERVER:
|
||||
g := server.bgpConfig.Global
|
||||
grpcReq.ResponseCh <- &GrpcResponse{
|
||||
Data: &g,
|
||||
}
|
||||
close(grpcReq.ResponseCh)
|
||||
case REQ_GLOBAL_RIB, REQ_LOCAL_RIB:
|
||||
arg := grpcReq.Data.(*api.GetRibRequest)
|
||||
rib := server.globalRib
|
||||
@@ -1717,6 +1711,19 @@ ERROR:
|
||||
return
|
||||
}
|
||||
|
||||
func (s *BgpServer) GetServer() (c *config.Global) {
|
||||
ch := make(chan struct{})
|
||||
defer func() { <-ch }()
|
||||
|
||||
s.mgmtCh <- func() {
|
||||
defer close(ch)
|
||||
|
||||
g := s.bgpConfig.Global
|
||||
c = &g
|
||||
}
|
||||
return c
|
||||
}
|
||||
|
||||
func (s *BgpServer) GetNeighbor() (l []*config.Neighbor) {
|
||||
ch := make(chan struct{})
|
||||
defer func() { <-ch }()
|
||||
|
||||
Reference in New Issue
Block a user