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

added new event type, reverted change to update event in mne service

parent 25cf7a73
No related branches found
No related tags found
1 merge request!568Resolve "Improve the event system by adding an extra Event for gNMI-Subscribe to replace the currently used Update Event"
This commit is part of merge request !568. Comments created here will be created in the context of that merge request.
......@@ -19,6 +19,9 @@ const (
// TypeDelete is a delete event.
TypeDelete = "delete"
// TypeSusbcribe is a gNMI subscribe event.
TypeSubscribe = "subscribe"
)
// NewAddEvent creates a new add event.
......@@ -48,12 +51,12 @@ func NewUpdateEvent(entityID uuid.UUID) Event {
}
}
// NewMneUpdateEvent creates a new update event for managed network elements.
func NewMneUpdateEvent(entityID uuid.UUID, pathsAndValues map[string]string) Event {
// NewGnmiSubscribeEvent creates a new gNMI subscribe event for managed network elements.
func NewGnmiSubscribeEvent(entityID uuid.UUID, pathsAndValues map[string]string) Event {
return Event{
ID: uuid.New(),
EntityID: entityID,
Type: TypeUpdate,
Type: TypeSubscribe,
PathsAndValuesMap: pathsAndValues,
}
}
......@@ -121,7 +121,7 @@ func TestNewUpdateEvent(t *testing.T) {
}
}
func TestNewMneUpdateEvent(t *testing.T) {
func TestNewGnmiSubscribeEvent(t *testing.T) {
type args struct {
entityID uuid.UUID
pathsAndValuesMap map[string]string
......@@ -132,7 +132,7 @@ func TestNewMneUpdateEvent(t *testing.T) {
want Event
}{
{
name: "should create a new update event",
name: "should create a new subscribe event",
args: args{
entityID: getTestEntityUUID(),
pathsAndValuesMap: map[string]string{"some/random/path": "val"},
......@@ -140,25 +140,25 @@ func TestNewMneUpdateEvent(t *testing.T) {
want: Event{
ID: uuid.New(),
EntityID: getTestEntityUUID(),
Type: TypeUpdate,
Type: TypeSubscribe,
PathsAndValuesMap: map[string]string{"some/random/path": "val"},
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := NewMneUpdateEvent(tt.args.entityID, tt.args.pathsAndValuesMap)
got := NewGnmiSubscribeEvent(tt.args.entityID, tt.args.pathsAndValuesMap)
if !reflect.DeepEqual(got.EntityID, tt.want.EntityID) {
t.Errorf("NewMneUpdateEvent().EntityID = %v, want %v", got, tt.want)
t.Errorf("NewGnmiSubscribeEvent().EntityID = %v, want %v", got, tt.want)
}
if !reflect.DeepEqual(got.Type, tt.want.Type) {
t.Errorf("NewMneUpdateEvent().Type = %v, want %v", got, tt.want)
t.Errorf("NewGnmiSubscribeEvent().Type = %v, want %v", got, tt.want)
}
if !reflect.DeepEqual(got.PathsAndValuesMap, tt.want.PathsAndValuesMap) {
t.Errorf("NewMneUpdateEvent().PathsAndValuesMap = %v, want %v", got, tt.want)
t.Errorf("NewGnmiSubscribeEvent().PathsAndValuesMap = %v, want %v", got, tt.want)
}
})
}
......
......@@ -146,7 +146,7 @@ func (s *NetworkElementService) UpdateModel(networkElementID uuid.UUID, modelAsS
}
// TODO (faseid): check if we want to add the paths with values here instead of empty map!
pubEvent := event.NewMneUpdateEvent(networkElementID, map[string]string{})
pubEvent := event.NewUpdateEvent(networkElementID)
if err := s.eventService.PublishEvent(NetworkElementEventTopic, pubEvent); err != nil {
go func() {
s.eventService.Reconnect()
......@@ -169,7 +169,7 @@ func (s *NetworkElementService) Update(networkElementToUpdate networkelement.Net
}
// TODO (faseid): check if we want to add the paths with values here instead of empty map!
pubEvent := event.NewMneUpdateEvent(networkElementToUpdate.ID(), map[string]string{})
pubEvent := event.NewUpdateEvent(networkElementToUpdate.ID())
if err := s.eventService.PublishEvent(NetworkElementEventTopic, pubEvent); err != nil {
go func() {
s.eventService.Reconnect()
......
......@@ -201,7 +201,7 @@ func (n *NetworkElementWatcher) handleSubscribeResponseUpdate(resp *gpb.Subscrib
log.Errorf("Error trying to parse uuid, could not handle subscription response: %v", err)
}
pubEvent := event.NewMneUpdateEvent(mneID, pathsAndValues)
pubEvent := event.NewGnmiSubscribeEvent(mneID, pathsAndValues)
if err := n.eventService.PublishEvent(NetworkElementEventTopic, pubEvent); err != nil {
go func() {
n.eventService.Reconnect()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment