Skip to content

Commit

Permalink
Merge pull request #25 from Kuadrant/fix/propagate
Browse files Browse the repository at this point in the history
controller: single propagation of delta events
  • Loading branch information
guicassolato authored Aug 29, 2024
2 parents e963418 + e425713 commit 5445f17
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,27 +222,20 @@ func (c *Controller) add(obj Object) {
defer c.Unlock()

c.cache.Add(obj)
c.propagate([]ResourceEvent{{obj.GetObjectKind().GroupVersionKind().GroupKind(), CreateEvent, nil, obj}})
}

func (c *Controller) update(oldObj, newObj Object) {
func (c *Controller) update(_, newObj Object) {
c.Lock()
defer c.Unlock()

if oldObj.GetGeneration() == newObj.GetGeneration() {
return
}

c.cache.Add(newObj)
c.propagate([]ResourceEvent{{newObj.GetObjectKind().GroupVersionKind().GroupKind(), UpdateEvent, oldObj, newObj}})
}

func (c *Controller) delete(obj Object) {
c.Lock()
defer c.Unlock()

c.cache.Delete(obj)
c.propagate([]ResourceEvent{{obj.GetObjectKind().GroupVersionKind().GroupKind(), DeleteEvent, obj, nil}})
}

func (c *Controller) propagate(resourceEvents []ResourceEvent) {
Expand Down

0 comments on commit 5445f17

Please sign in to comment.