From 277815f83a57cb5d3366bf9788560a957c329239 Mon Sep 17 00:00:00 2001 From: newb1er Date: Tue, 4 Jun 2024 12:45:16 +0800 Subject: [PATCH] fix: instantiate processor in `NewApp()` --- internal/sbi/server.go | 14 ++++++++++---- pkg/service/init.go | 3 +++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/internal/sbi/server.go b/internal/sbi/server.go index 21cf2f1..88c67d3 100644 --- a/internal/sbi/server.go +++ b/internal/sbi/server.go @@ -19,18 +19,24 @@ import ( logger_util "github.com/free5gc/util/logger" ) -type Server struct { +type nssfApp interface { app.NssfApp + Processor() *processor.Processor +} + +type Server struct { + nssfApp + httpServer *http.Server router *gin.Engine processor *processor.Processor } -func NewServer(nssf app.NssfApp, tlsKeyLogPath string) *Server { +func NewServer(nssf nssfApp, tlsKeyLogPath string) *Server { s := &Server{ - NssfApp: nssf, - processor: processor.NewProcessor(nssf), + nssfApp: nssf, + processor: nssf.Processor(), } s.router = newRouter(s) diff --git a/pkg/service/init.go b/pkg/service/init.go index 724da34..7a298d4 100644 --- a/pkg/service/init.go +++ b/pkg/service/init.go @@ -45,6 +45,9 @@ func NewApp(cfg *factory.Config, tlsKeyLogPath string) (*NssfApp, error) { nssf.SetLogLevel(cfg.GetLogLevel()) nssf.SetReportCaller(cfg.GetLogReportCaller()) + processor := processor.NewProcessor(nssf) + nssf.processor = processor + consumer := consumer.NewConsumer(nssf) nssf.consumer = consumer