Skip to content

Commit

Permalink
refactor: use Consumer() instead of consumer.GetConsumer()
Browse files Browse the repository at this point in the history
  • Loading branch information
ianchen0119 committed May 14, 2024
1 parent a0c9e61 commit 9efc266
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
2 changes: 0 additions & 2 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"github.com/free5gc/amf/internal/logger"
"github.com/free5gc/amf/pkg/factory"
"github.com/free5gc/amf/pkg/service"
// "github.com/free5gc/amf/pkg/utils"
logger_util "github.com/free5gc/util/logger"
"github.com/free5gc/util/version"
)
Expand Down Expand Up @@ -71,7 +70,6 @@ func action(cliCtx *cli.Context) error {
}
factory.AmfConfig = cfg

// appStart, appStop := utils.InitFunc(tlsKeyLogPath)
amf, err := service.NewApp(ctx, cfg, tlsKeyLogPath)
if err != nil {
return err
Expand Down
4 changes: 2 additions & 2 deletions internal/sbi/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,12 @@ func newRouter(s *Server) *gin.Engine {

func (s *Server) Run(traceCtx context.Context, wg *sync.WaitGroup) error {
var profile models.NfProfile
if profileTmp, err1 := consumer.GetConsumer().BuildNFInstance(s.Context()); err1 != nil {
if profileTmp, err1 := s.Consumer().BuildNFInstance(s.Context()); err1 != nil {
logger.InitLog.Error("Build AMF Profile Error")
} else {
profile = profileTmp
}
_, nfId, err_reg := consumer.GetConsumer().SendRegisterNFInstance(s.Context().NrfUri, s.Context().NfId, profile)
_, nfId, err_reg := s.Consumer().SendRegisterNFInstance(s.Context().NrfUri, s.Context().NfId, profile)
if err_reg != nil {
logger.InitLog.Warnf("Send Register NF Instance failed: %+v", err_reg)
} else {
Expand Down
3 changes: 2 additions & 1 deletion pkg/service/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ type AmfAppInterface interface {
app.App
consumer.ConsumerAmf
Consumer() *consumer.Consumer
Processor() *processor.Processor
}

var AMF AmfAppInterface
Expand Down Expand Up @@ -151,7 +152,7 @@ func (a *AmfApp) Terminate() {
a.cancel()
a.CallServerStop()
// deregister with NRF
problemDetails, err_deg := consumer.GetConsumer().SendDeregisterNFInstance()
problemDetails, err_deg := a.Consumer().SendDeregisterNFInstance()
if problemDetails != nil {
logger.InitLog.Errorf("Deregister NF instance Failed Problem[%+v]", problemDetails)
} else if err_deg != nil {
Expand Down

0 comments on commit 9efc266

Please sign in to comment.