Skip to content

Commit

Permalink
chore: fix nrf_service & nf_management for ctx
Browse files Browse the repository at this point in the history
  • Loading branch information
KunLee76 committed Sep 18, 2024
1 parent c9e20c3 commit 8e15619
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
3 changes: 2 additions & 1 deletion internal/sbi/consumer/nrf_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ func (s *nnrfService) getNFManagementClient(uri string) *NFManagement.APIClient
}

func (s *nnrfService) SendNFStatusNotify(
ctx context.Context,
notification_event models.NotificationEventType,
nfInstanceUri string,
url string,
Expand Down Expand Up @@ -73,7 +74,7 @@ func (s *nnrfService) SendNFStatusNotify(
}

res, err := client.SubscriptionsCollectionApi.CreateSubscriptionOnNFStatusEventPost(
context.TODO(), nfInstanceUri, request)
ctx, nfInstanceUri, request)
if err != nil {
logger.NfmLog.Infof("Notify fail: %v", err)
problemDetails := &models.ProblemDetails{
Expand Down
17 changes: 13 additions & 4 deletions internal/sbi/processor/nf_management.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package processor

import (
"context"
"encoding/json"
"fmt"
"net/http"
Expand Down Expand Up @@ -294,8 +295,10 @@ func (p *Processor) NFDeregisterProcedure(nfInstanceID string) *models.ProblemDe
// set info for NotificationData
Notification_event := models.NotificationEventType_DEREGISTERED

ctx := context.Background()

for _, uri := range uriList {
problemDetails := p.Consumer().SendNFStatusNotify(Notification_event, nfInstanceUri, uri, nil)
problemDetails := p.Consumer().SendNFStatusNotify(ctx, Notification_event, nfInstanceUri, uri, nil)
if problemDetails != nil {
return problemDetails
}
Expand Down Expand Up @@ -361,8 +364,10 @@ func (p *Processor) UpdateNFInstanceProcedure(nfInstanceID string, patchJSON []b
Notification_event := models.NotificationEventType_PROFILE_CHANGED
nfInstanceUri := nrf_context.GetNfInstanceURI(nfInstanceID)

ctx := context.Background()

for _, uri := range uriList {
p.Consumer().SendNFStatusNotify(Notification_event, nfInstanceUri, uri, &nfProfiles[0])
p.Consumer().SendNFStatusNotify(ctx, Notification_event, nfInstanceUri, uri, &nfProfiles[0])
}
return nf
}
Expand Down Expand Up @@ -460,9 +465,11 @@ func (p *Processor) NFRegisterProcedure(
Notification_event := models.NotificationEventType_PROFILE_CHANGED
nfInstanceUri := locationHeaderValue

ctx := context.Background()

// receive the rsp from handler
for _, uri := range uriList {
problemDetails := p.Consumer().SendNFStatusNotify(Notification_event, nfInstanceUri, uri, nfProfile)
problemDetails := p.Consumer().SendNFStatusNotify(ctx, Notification_event, nfInstanceUri, uri, nfProfile)
if problemDetails != nil {
util.GinProblemJson(c, problemDetails)
return
Expand All @@ -482,8 +489,10 @@ func (p *Processor) NFRegisterProcedure(
// Add NF Register Conter
p.Context().AddNfRegister()

ctx := context.Background()

for _, uri := range uriList {
problemDetails := p.Consumer().SendNFStatusNotify(Notification_event, nfInstanceUri, uri, nfProfile)
problemDetails := p.Consumer().SendNFStatusNotify(ctx, Notification_event, nfInstanceUri, uri, nfProfile)
if problemDetails != nil {
util.GinProblemJson(c, problemDetails)
return
Expand Down

0 comments on commit 8e15619

Please sign in to comment.