diff --git a/main.go b/main.go index 7f69679..2d65fe4 100644 --- a/main.go +++ b/main.go @@ -20,9 +20,7 @@ func main() { isReadinessReady := false go probes.InitReadinessV1(&isReadinessReady) - gateway := gateway.NewGateway() - isReadinessReady = true - gateway.SetupAndServe() + gateway.NewGateway(&isReadinessReady).SetupAndServe() } // DisplayBuildTag outputs the bulid tag of the current release diff --git a/pkg/notificationhandle.go b/pkg/notificationhandle.go index fdf4fcd..0ec31d6 100644 --- a/pkg/notificationhandle.go +++ b/pkg/notificationhandle.go @@ -38,10 +38,11 @@ type Gateway struct { incomingConnections Connections outgoingConnectionsMutex *sync.Mutex rootGatewayURL string + isReadinessReady *bool } // NewGateway creates a new Gateway -func NewGateway() *Gateway { +func NewGateway(isReadinessReady *bool) *Gateway { rootGatewayUrl := getRootGwUrl() @@ -51,6 +52,7 @@ func NewGateway() *Gateway { incomingConnections: *NewConnectionsObj(), outgoingConnectionsMutex: &sync.Mutex{}, rootGatewayURL: rootGatewayUrl, + isReadinessReady: isReadinessReady, } } @@ -78,6 +80,7 @@ func (nh *Gateway) WebsocketNotificationHandler(w http.ResponseWriter, r *http.R // append new route newConn, id := nh.incomingConnections.Append(notificationAtt, conn) logger.L().Info("accepting websocket connection", helpers.String("url query", r.URL.RawQuery), helpers.Int("id", id), helpers.Int("number of incoming websockets", nh.incomingConnections.Len())) + *nh.isReadinessReady = true // ----------------------------------------------------- 3 // register route in master if master configured