Skip to content

Commit

Permalink
fix problem with monitor connection (#473)
Browse files Browse the repository at this point in the history
Signed-off-by: anastasia.malysheva <anastasia.malysheva@xored.com>
  • Loading branch information
anastasia-malysheva authored Jul 29, 2022
1 parent fcb38c1 commit 59fd2ef
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ func main() {
u := nsurl.NSURL(config.NetworkServices[i])

id := fmt.Sprintf("%s-%d", config.Name, i)

var monitoredConnections map[string]*networkservice.Connection
monitorCtx, cancelMonitor := context.WithTimeout(signalCtx, config.RequestTimeout)
defer cancelMonitor()

Expand All @@ -258,12 +258,14 @@ func main() {
},
})
if err != nil {
log.FromContext(ctx).Fatal(err.Error())
log.FromContext(ctx).Fatalf("error from monitorConnectionClient", err.Error())
}

event, err := stream.Recv()
if err != nil {
log.FromContext(ctx).Fatal(err.Error())
log.FromContext(ctx).Errorf("error from monitorConnection stream", err.Error())
} else {
monitoredConnections = event.Connections
}
cancelMonitor()

Expand All @@ -282,7 +284,7 @@ func main() {
},
}

for _, conn := range event.Connections {
for _, conn := range monitoredConnections {
path := conn.GetPath()
if path.Index == 1 && path.PathSegments[0].Id == id && conn.Mechanism.Type == u.Mechanism().Type {
request.Connection = conn
Expand Down

0 comments on commit 59fd2ef

Please sign in to comment.