catalog: Refactor repeater() for clarity
@@ -19,10 +19,16 @@ 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 {
+ 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)
@@ -32,7 +38,6 @@ func (mc *MeshCatalog) repeater() {
}
}
}
-}
func (mc *MeshCatalog) handleAnnouncement(ann announcements.Announcement) {
if ann.Type == announcements.EndpointDeleted {
