Skip to content

Conversation

gbjk
Copy link
Collaborator

@gbjk gbjk commented Aug 18, 2025

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

  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

How has this been tested

  • go test ./... -race
  • golangci-lint run

gbjk added 21 commits August 13, 2025 18:16
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
@gbjk gbjk self-assigned this Aug 18, 2025
@Copilot Copilot AI review requested due to automatic review settings August 18, 2025 08:14
@gbjk gbjk added the nomerge requires dependency This pull request is dependent on another, so it can't be merged until the dependent one is merged label Aug 18, 2025
Copy link
Contributor

@Copilot Copilot AI left a 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() and MessageSequence() 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

@gbjk gbjk moved this to In review in GoCryptoTrader Kanban Aug 18, 2025
@gbjk gbjk added the review me This pull request is ready for review label Aug 19, 2025
Copy link
Collaborator

@shazbert shazbert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good stuff!

Copy link
Collaborator

@shazbert shazbert left a 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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
nomerge requires dependency This pull request is dependent on another, so it can't be merged until the dependent one is merged review me This pull request is ready for review
Projects
Status: In review
Development

Successfully merging this pull request may close these issues.

2 participants