Skip to content

Commit

Permalink
catalog: Refactor repeater() for clarity (openservicemesh#2032)
Browse files Browse the repository at this point in the history
  • Loading branch information
draychev committed Nov 18, 2020
1 parent 6262f4c commit 47be253
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions pkg/catalog/repeater.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,20 @@ func (mc *MeshCatalog) repeater() {
cases, caseNames := mc.getCases()
for {
if chosenIdx, message, ok := reflect.Select(cases); ok {
if ann, ok := message.Interface().(announcements.Announcement); ok {
mc.handleAnnouncement(ann)
ann, ok := message.Interface().(announcements.Announcement)
if !ok {
log.Error().Msgf("Repeater received a interface{} message, which is not an Announcement")
continue
}

log.Trace().Msgf("Handling announcement from %s: %+v", caseNames[chosenIdx], ann)

mc.handleAnnouncement(ann)

log.Trace().Msgf("Received announcement from %s", caseNames[chosenIdx])
delta := time.Since(lastUpdateAt)
if delta >= updateAtMostEvery {
mc.broadcastToAllProxies(ann)
lastUpdateAt = time.Now()
}
delta := time.Since(lastUpdateAt)
if delta >= updateAtMostEvery {
mc.broadcastToAllProxies(ann)
lastUpdateAt = time.Now()
}
}
}
Expand Down

0 comments on commit 47be253

Please sign in to comment.