Skip to content
Snippets Groups Projects
Commit 954a867b authored by Fabian Seidl's avatar Fabian Seidl
Browse files

added missing error handling

parent 2d940250
Branches
Tags
3 merge requests!376Add additional example application hostname-checker,!343Add basic application framework and example application to show interaction between events an NBI,!342Resolve "Add an option to send gNMI Subscribe requests via SBI"
Pipeline #108234 failed
This commit is part of merge request !342. Comments created here will be created in the context of that merge request.
...@@ -10,6 +10,7 @@ import ( ...@@ -10,6 +10,7 @@ import (
interfaces "code.fbi.h-da.de/danet/gosdn/controller/interfaces/event" interfaces "code.fbi.h-da.de/danet/gosdn/controller/interfaces/event"
amqp "github.com/rabbitmq/amqp091-go" amqp "github.com/rabbitmq/amqp091-go"
"github.com/sirupsen/logrus"
) )
// EventService is used to setup a connection to a broker and publish events to topics. // EventService is used to setup a connection to a broker and publish events to topics.
...@@ -78,5 +79,7 @@ func (e *EventService) PublishEvent(topic string, event event.Event) error { ...@@ -78,5 +79,7 @@ func (e *EventService) PublishEvent(topic string, event event.Event) error {
// CloseConnection closes an exisiting connection. // CloseConnection closes an exisiting connection.
func (e *EventService) CloseConnection() { func (e *EventService) CloseConnection() {
e.connection.Close() if err := e.connection.Close(); err != nil {
logrus.Error(err)
}
} }
...@@ -9,6 +9,7 @@ import ( ...@@ -9,6 +9,7 @@ import (
"code.fbi.h-da.de/danet/gosdn/controller/nucleus/types" "code.fbi.h-da.de/danet/gosdn/controller/nucleus/types"
"code.fbi.h-da.de/danet/gosdn/forks/goarista/gnmi" "code.fbi.h-da.de/danet/gosdn/forks/goarista/gnmi"
gpb "github.com/openconfig/gnmi/proto/gnmi" gpb "github.com/openconfig/gnmi/proto/gnmi"
"github.com/sirupsen/logrus"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
) )
...@@ -62,7 +63,9 @@ func (d *DeviceWatcher) callSubscribe(device device.Device, opts *gnmi.Subscribe ...@@ -62,7 +63,9 @@ func (d *DeviceWatcher) callSubscribe(device device.Device, opts *gnmi.Subscribe
ctx := context.Background() ctx := context.Background()
ctx = context.WithValue(ctx, types.CtxKeyOpts, opts) ctx = context.WithValue(ctx, types.CtxKeyOpts, opts)
device.Transport().SubscribeInternal(ctx, handleSubscribeRepsonse) if err := device.Transport().SubscribeInternal(ctx, handleSubscribeRepsonse); err != nil {
logrus.Error(err)
}
} }
func handleSubscribeRepsonse(resp *gpb.SubscribeResponse) { func handleSubscribeRepsonse(resp *gpb.SubscribeResponse) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment