diff --git a/go.mod b/go.mod index 95e5734..37e0437 100644 --- a/go.mod +++ b/go.mod @@ -13,7 +13,6 @@ require ( github.com/google/uuid v1.3.0 github.com/pkg/errors v0.9.1 github.com/sirupsen/logrus v1.8.1 - github.com/stretchr/testify v1.8.3 github.com/urfave/cli v1.22.5 gopkg.in/yaml.v2 v2.4.0 ) @@ -22,7 +21,6 @@ require ( github.com/bytedance/sonic v1.9.1 // indirect github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d // indirect - github.com/davecgh/go-spew v1.1.1 // indirect github.com/gabriel-vasile/mimetype v1.4.2 // indirect github.com/gin-contrib/sse v0.1.0 // indirect github.com/go-playground/locales v0.14.1 // indirect @@ -40,7 +38,6 @@ require ( github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect github.com/pelletier/go-toml/v2 v2.0.8 // indirect - github.com/pmezard/go-difflib v1.0.0 // indirect github.com/russross/blackfriday/v2 v2.0.1 // indirect github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect github.com/tim-ywliu/nested-logrus-formatter v1.3.2 // indirect diff --git a/internal/sbi/consumer/nrf_service.go b/internal/sbi/consumer/nrf_service.go index 2040f84..73285c5 100644 --- a/internal/sbi/consumer/nrf_service.go +++ b/internal/sbi/consumer/nrf_service.go @@ -150,7 +150,7 @@ func (s *nnrfService) RegisterNFInstance(ctx context.Context) ( var nf models.NfProfile var res *http.Response for { - nf, res, err = client.NFInstanceIDDocumentApi.RegisterNFInstance(context.TODO(), ausfContext.NfId, nfProfile) + nf, res, err = client.NFInstanceIDDocumentApi.RegisterNFInstance(ctx, ausfContext.NfId, nfProfile) if err != nil || res == nil { logger.ConsumerLog.Errorf("AUSF register to NRF Error[%v]", err) time.Sleep(2 * time.Second) diff --git a/internal/sbi/server.go b/internal/sbi/server.go index a4db49f..aaab0cc 100644 --- a/internal/sbi/server.go +++ b/internal/sbi/server.go @@ -78,7 +78,11 @@ func (s *Server) Run(traceCtx context.Context, wg *sync.WaitGroup) error { return nil } -func (s *Server) Stop() { +func (s *Server) Shutdown() { + s.shutdownHttpServer() +} + +func (s *Server) shutdownHttpServer() { const defaultShutdownTimeout time.Duration = 2 * time.Second if s.httpServer != nil { diff --git a/pkg/service/init.go b/pkg/service/init.go index f4f8217..b69683a 100644 --- a/pkg/service/init.go +++ b/pkg/service/init.go @@ -93,7 +93,7 @@ func (a *AusfApp) Config() *factory.Config { return a.cfg } -func (c *AusfApp) SetLogEnable(enable bool) { +func (a *AusfApp) SetLogEnable(enable bool) { logger.MainLog.Infof("Log enable is set to [%v]", enable) if enable && logger.Log.Out == os.Stderr { return @@ -101,7 +101,7 @@ func (c *AusfApp) SetLogEnable(enable bool) { return } - c.Config().SetLogEnable(enable) + a.Config().SetLogEnable(enable) if enable { logger.Log.SetOutput(os.Stderr) } else { @@ -109,7 +109,7 @@ func (c *AusfApp) SetLogEnable(enable bool) { } } -func (c *AusfApp) SetLogLevel(level string) { +func (a *AusfApp) SetLogLevel(level string) { lvl, err := logrus.ParseLevel(level) if err != nil { logger.MainLog.Warnf("Log level [%s] is invalid", level) @@ -121,17 +121,17 @@ func (c *AusfApp) SetLogLevel(level string) { return } - c.Config().SetLogLevel(level) + a.Config().SetLogLevel(level) logger.Log.SetLevel(lvl) } -func (c *AusfApp) SetReportCaller(reportCaller bool) { +func (a *AusfApp) SetReportCaller(reportCaller bool) { logger.MainLog.Infof("Report Caller is set to [%v]", reportCaller) if reportCaller == logger.Log.ReportCaller { return } - c.Config().SetLogReportCaller(reportCaller) + a.Config().SetLogReportCaller(reportCaller) logger.Log.SetReportCaller(reportCaller) } @@ -160,13 +160,13 @@ func (a *AusfApp) listenShutdownEvent() { a.Terminate() } -func (c *AusfApp) Terminate() { +func (a *AusfApp) Terminate() { logger.MainLog.Infof("Terminating AUSF...") - c.cancel() - c.CallServerStop() + a.cancel() + a.CallServerStop() // deregister with NRF - problemDetails, err := c.Consumer().SendDeregisterNFInstance() + problemDetails, err := a.Consumer().SendDeregisterNFInstance() if problemDetails != nil { logger.MainLog.Errorf("Deregister NF instance Failed Problem[%+v]", problemDetails) } else if err != nil { @@ -179,7 +179,7 @@ func (c *AusfApp) Terminate() { func (a *AusfApp) CallServerStop() { if a.sbiServer != nil { - a.sbiServer.Stop() + a.sbiServer.Shutdown() } }