Skip to content

Commit

Permalink
Merge pull request #6918 from onflow/illia-malachyn/6754-deprecate-le…
Browse files Browse the repository at this point in the history
…gacy-websockets-stream-api

[Access] Add deprecate message to legacy ws handler and controller
  • Loading branch information
peterargue authored Jan 23, 2025
2 parents 92474d3 + 9cf78e9 commit bcb042d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
3 changes: 3 additions & 0 deletions engine/access/rest/router/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ func (b *RouterBuilder) AddRestRoutes(
}

// AddLegacyWebsocketsRoutes adds WebSocket routes to the router.
//
// Deprecated: Use AddWebsocketsRoute instead, which allows managing multiple streams with
// a single endpoint.
func (b *RouterBuilder) AddLegacyWebsocketsRoutes(
stateStreamApi state_stream.API,
chain flow.Chain,
Expand Down
3 changes: 1 addition & 2 deletions engine/access/rest/websockets/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ func NewWebSocketHandler(
}

func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
//TODO: change to accept topic instead of URL
logger := h.HttpHandler.Logger.With().Str("websocket_subscribe_url", r.URL.String()).Logger()
logger := h.HttpHandler.Logger.With().Str("component", "websocket-handler").Logger()

err := h.HttpHandler.VerifyRequest(w, r)
if err != nil {
Expand Down
2 changes: 2 additions & 0 deletions engine/access/rest/websockets/legacy/websocket_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import (

// WebsocketController holds the necessary components and parameters for handling a WebSocket subscription.
// It manages the communication between the server and the WebSocket client for subscribing.
//
// Deprecated: Use websockets.Controller which allows managing multiple subscriptions with a single connection.
type WebsocketController struct {
logger zerolog.Logger
conn *websocket.Conn // the WebSocket connection for communication with the client
Expand Down

0 comments on commit bcb042d

Please sign in to comment.