Skip to content

Commit

Permalink
fix: align naming convention
Browse files Browse the repository at this point in the history
  • Loading branch information
TYuan0816 committed Jun 9, 2024
1 parent 1582389 commit 44f7cfd
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 16 deletions.
3 changes: 0 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand All @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion internal/sbi/consumer/nrf_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 5 additions & 1 deletion internal/sbi/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
22 changes: 11 additions & 11 deletions pkg/service/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,23 +93,23 @@ 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
} else if !enable && logger.Log.Out == io.Discard {
return
}

c.Config().SetLogEnable(enable)
a.Config().SetLogEnable(enable)
if enable {
logger.Log.SetOutput(os.Stderr)
} else {
logger.Log.SetOutput(io.Discard)
}
}

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)
Expand All @@ -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)
}

Expand Down Expand Up @@ -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 {
Expand All @@ -179,7 +179,7 @@ func (c *AusfApp) Terminate() {

func (a *AusfApp) CallServerStop() {
if a.sbiServer != nil {
a.sbiServer.Stop()
a.sbiServer.Shutdown()
}
}

Expand Down

0 comments on commit 44f7cfd

Please sign in to comment.