Skip to content

Commit

Permalink
match naming with master changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan O'Hara-Reid committed Feb 2, 2025
1 parent 70ff950 commit 64fc9c2
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 21 deletions.
8 changes: 2 additions & 6 deletions exchanges/gateio/gateio_websocket.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,15 +173,11 @@ func (g *Gateio) WsHandleSpotData(_ context.Context, conn stream.Connection, res
}

if push.RequestID != "" {
// TODO: RouteIncomingWebsocketData should be used here and updated to return error.
return g.Websocket.Match.RequireMatchWithData(push.RequestID, respRaw)
return conn.RequireMatchWithData(push.RequestID, respRaw)
}

if push.Event == subscribeEvent || push.Event == unsubscribeEvent {
if !conn.RouteIncomingWebsocketData(push.ID, respRaw) {
return fmt.Errorf("couldn't match subscription message with ID: %d", push.ID)
}
return nil
return conn.RequireMatchWithData(push.ID, respRaw)
}

switch push.Channel { // TODO: Convert function params below to only use push.Result
Expand Down
5 changes: 1 addition & 4 deletions exchanges/gateio/gateio_websocket_futures.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,7 @@ func (g *Gateio) WsHandleFuturesData(_ context.Context, conn stream.Connection,
}

if push.Event == subscribeEvent || push.Event == unsubscribeEvent {
if !conn.RouteIncomingWebsocketData(push.ID, respRaw) {
return fmt.Errorf("couldn't match subscription message with ID: %d", push.ID)
}
return nil
return conn.RequireMatchWithData(push.ID, respRaw)
}

switch push.Channel {
Expand Down
5 changes: 1 addition & 4 deletions exchanges/gateio/gateio_websocket_option.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,10 +300,7 @@ func (g *Gateio) WsHandleOptionsData(_ context.Context, conn stream.Connection,
}

if push.Event == subscribeEvent || push.Event == unsubscribeEvent {
if !conn.RouteIncomingWebsocketData(push.ID, respRaw) {
return fmt.Errorf("couldn't match subscription message with ID: %d", push.ID)
}
return nil
return conn.RequireMatchWithData(push.ID, respRaw)
}

switch push.Channel {
Expand Down
5 changes: 2 additions & 3 deletions exchanges/stream/stream_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,8 @@ type Connection interface {
GetURL() string
Shutdown() error

// RouteIncomingWebsocketData routes incoming websocket data to the correct handler.
// Returns true if a handler was found and data was passed to it.
RouteIncomingWebsocketData(signature any, incoming []byte) (matched bool)
// RequireMatchWithData routes incoming data using the connection specific match system to the correct handler
RequireMatchWithData(signature any, incoming []byte) error
}

// Inspector is used to verify messages via SendMessageReturnResponsesWithInspection
Expand Down
7 changes: 3 additions & 4 deletions exchanges/stream/websocket_connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -380,8 +380,7 @@ func removeURLQueryString(url string) string {
return url
}

// RouteIncomingWebsocketData routes incoming websocket data to the correct handler.
// Returns true if a handler was found and data was passed to it.
func (w *WebsocketConnection) RouteIncomingWebsocketData(signature any, incoming []byte) (matched bool) {
return w.Match.IncomingWithData(signature, incoming)
// RequireMatchWithData routes incoming data using the connection specific match system to the correct handler
func (w *WebsocketConnection) RequireMatchWithData(signature any, incoming []byte) error {
return w.Match.RequireMatchWithData(signature, incoming)
}

0 comments on commit 64fc9c2

Please sign in to comment.