Skip to content

Commit

Permalink
backend: Add websocket multiplexer
Browse files Browse the repository at this point in the history
This adds websocket multiplexer to the backend. Frontend now make a
single websocket call to the backend. Once that connection is
established with the backend it will send message to the backend with
appropriate data. Backend will open multiple websockets and act as a
proxy to the frontend. It will make request to k8s server and return
data to frontend.

This also adds retry logic if the connection is broken between frontend
and backend.

Fixes: #1802

Signed-off-by: Kautilya Tripathi <ktripathi@microsoft.com>
  • Loading branch information
knrt10 committed Oct 24, 2024
1 parent 34926f2 commit bf2ec6d
Show file tree
Hide file tree
Showing 4 changed files with 1,064 additions and 0 deletions.
4 changes: 4 additions & 0 deletions backend/cmd/headlamp.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ type HeadlampConfig struct {
proxyURLs []string
cache cache.Cache[interface{}]
kubeConfigStore kubeconfig.ContextStore
multiplexer *Multiplexer
}

const DrainNodeCacheTTL = 20 // seconds
Expand Down Expand Up @@ -1599,6 +1600,9 @@ func (c *HeadlampConfig) addClusterSetupRoute(r *mux.Router) {

// Rename a cluster
r.HandleFunc("/cluster/{name}", c.renameCluster).Methods("PUT")

// Websocket connections
r.HandleFunc("/wsMutliplexer", c.multiplexer.HandleClientWebSocket)
}

/*
Expand Down
Loading

0 comments on commit bf2ec6d

Please sign in to comment.