Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set readiness to true after successful ws connection #36

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion pkg/notificationhandle.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -51,6 +52,7 @@ func NewGateway() *Gateway {
incomingConnections: *NewConnectionsObj(),
outgoingConnectionsMutex: &sync.Mutex{},
rootGatewayURL: rootGatewayUrl,
isReadinessReady: isReadinessReady,
}
}

Expand Down Expand Up @@ -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
Expand Down
Loading