Unverified Commit 8f6343cf authored by Natalie Serrino's avatar Natalie Serrino Committed by Copybara
Browse files

VizierWatcher should call onVizier handlers as goroutines, not blocking calls


Summary: VizierWatcher is responsible for watching for Viziers and calling onVizier handlers that are specified by the consuemr of the VizierWatcher. VizierWatcher reads from a NATS channel and currently calls these handlers in a blocking way. However, the handlers themselves might be doing non-trivial work, and we shouldn't block reading from the NATS subscription on those functions. This diff ensures that we wrap onVizier calls in a go routine so that this work does not block the reading from the NATS channel.

Test Plan: n/a

Reviewers: zasgar, vihang, michelle

Reviewed By: vihang
Signed-off-by: default avatarNatalie Serrino <nserrino@pixielabs.ai>

Differential Revision: https://phab.corp.pixielabs.ai/D10497

GitOrigin-RevId: a7f1d973840ad4f9a9fca943b62b420bf06bb199
parent 9d9af202
Showing with 2 additions and 2 deletions
+2 -2
......@@ -101,7 +101,7 @@ func (w *Watcher) runWatch() {
}
vzID := utils.UUIDFromProtoOrNil(vcMsg.VizierID)
orgID := utils.UUIDFromProtoOrNil(vcMsg.OrgID)
w.onVizier(vzID, orgID, vcMsg.K8sUID)
go w.onVizier(vzID, orgID, vcMsg.K8sUID)
}
}
}
......@@ -140,7 +140,7 @@ func (w *Watcher) RegisterVizierHandler(fn VizierHandlerFn) error {
for _, vz := range vzmgrResp.Viziers {
vzID := utils.UUIDFromProtoOrNil(vz.VizierID)
orgID := utils.UUIDFromProtoOrNil(vz.OrgID)
w.onVizier(vzID, orgID, vz.K8sUID)
go w.onVizier(vzID, orgID, vz.K8sUID)
}
return nil
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment