From 504ce7feb99d387f582ee62218d3f222d18bc3d4 Mon Sep 17 00:00:00 2001 From: Abhishek Kondur Date: Mon, 10 Jul 2023 16:56:03 +0530 Subject: [PATCH] keep mq updates in a single go func --- controllers/hosts.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/controllers/hosts.go b/controllers/hosts.go index 06e7b975..fa27cfdf 100644 --- a/controllers/hosts.go +++ b/controllers/hosts.go @@ -258,13 +258,14 @@ func addHostToNetwork(w http.ResponseWriter, r *http.Request) { return } logger.Log(1, "added new node", newNode.ID.String(), "to host", currHost.Name) - - mq.HostUpdate(&models.HostUpdate{ - Action: models.JoinHostToNetwork, - Host: *currHost, - Node: *newNode, - }) - go mq.PublishPeerUpdate() + go func() { + mq.HostUpdate(&models.HostUpdate{ + Action: models.JoinHostToNetwork, + Host: *currHost, + Node: *newNode, + }) + mq.PublishPeerUpdate() + }() logger.Log(2, r.Header.Get("user"), fmt.Sprintf("added host %s to network %s", currHost.Name, network)) w.WriteHeader(http.StatusOK) }