-
Notifications
You must be signed in to change notification settings - Fork 874
Websocket: Remove GenerateMessageID #2008
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
base: master
Are you sure you want to change the base?
Conversation
Switch from int to string IDs so we can use UUID.v7 instead of (the only) local high precision message id implementation
This moves away from centralising message ids. There's no real benefit to moving them to a central generator, since we can one-line it, and reduce our testing plane and complexity. And it's more concise for exchanges to say "I'm using this UUID".
Continued overall direction to remove the closed-loop of e => conn => e roundtrip for message ids
This method removes the either/or nature of message id generation. We don't tie the message ids to connections, or to anything. Consumers just call whichever they want, or even combine them as they want. Anything more complicated will need a separate installation anyway
Tested CID - It accepts 53 bits only for an int, so MessageSequence makes sense. Can't use MessageID
Moved all MessageID usage into funcs and onto base methods, to remove the closed loop of message IDs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR removes connection-specific message ID generators from websocket implementations, replacing them with UUID-based message IDs where exchanges need unique identifiers. This simplifies the codebase by eliminating the closed-loop pattern where exchanges would set up generators but be the only consumers.
Key changes:
- Introduces
MessageID()
andMessageSequence()
methods to the exchange base struct - Switches most exchanges from integer-based message IDs to UUID V7 string format
- Removes
RequestIDGenerator
configuration from websocket connection setup
Reviewed Changes
Copilot reviewed 35 out of 35 changed files in this pull request and generated 4 comments.
Show a summary per file
File | Description |
---|---|
exchanges/exchange.go | Adds UUID V7 MessageID() and sequential MessageSequence() methods to Base |
exchanges/okx/okx_wrapper.go | Implements custom MessageID() returning 32-character hex UUID for OKX format requirements |
exchanges/hitbtc/hitbtc_types.go | Changes websocket request/response ID fields from int64 to string |
exchanges/deribit/deribit_websocket.go | Refactors heartbeat handling and switches to UUID message IDs |
exchange/websocket/connection.go | Removes GenerateMessageID functionality from websocket connections |
Multiple exchange files | Updates websocket implementations to use new MessageID/MessageSequence methods |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good stuff!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nothing more from me, thanks!
This change removes the outstanding usages of connection specific message id generators and removes the closed-loop where exchanges would set a generator function in setup, but then be the only thing to call it.
Where possible we've switched to UUIDs, particularly when the exchange wants something unique.
Depends on #1995
Type of change
How has this been tested