Skip to content
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

websocket/gateio: Add request functions for websocket multi-connection [SPOT] #1598

Open
wants to merge 165 commits into
base: master
Choose a base branch
from

Conversation

shazbert
Copy link
Collaborator

@shazbert shazbert commented Jul 31, 2024

PR Description

This adds initial functionality for outbound websocket requests on GateIO using multi connection management.

Dependencies:

Please delete options that are not relevant and add an x in [] as item is complete.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How has this been tested

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration and
also consider improving test coverage whilst working on a certain feature or package.

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

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation and regenerated documentation via the documentation tool
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally and on Github Actions with my changes
  • Any dependent changes have been merged and published in downstream modules

shazbert added 30 commits July 14, 2024 16:13
…larity on purpose. Change connections map to point to candidate to track subscriptions for future dynamic connections holder and drop struct ConnectionDetails.
…rror but websocket frame error or anything really makes the reader routine return and then connection never cycles and the buffer gets filled.

* Handle reconnection via an errors.Is check which is simpler and in that scope allow for quick disconnect reconnect without waiting for connection cycle.
* Dial now uses code from DialContext but just calls context.Background()
* Don't allow reader to return on parse binary response error. Just output error and return a non nil response
…would hang connection reader for eternity.
@shazbert shazbert requested a review from gbjk November 23, 2024 21:06
Copy link
Collaborator

@gbjk gbjk left a comment

Choose a reason for hiding this comment

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

I'm happy.

2 conversations outstanding where I was asking for changes, but they're trivial.
Address or Ignore :)

@shazbert shazbert 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 Dec 5, 2024
@shazbert
Copy link
Collaborator Author

shazbert commented Dec 5, 2024

This now requires dependency #1733 for spot trading rate limits

@shazbert shazbert mentioned this pull request Dec 5, 2024
15 tasks
Copy link
Collaborator

@gloriousCode gloriousCode left a comment

Choose a reason for hiding this comment

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

I'm happy. Only one change which is just a rename. Once ratelimits is merged then I can do a final look

Comment on lines 54 to 56
// EnsureMatchWithData validates that incoming data matches a request's signature.
// If a match is found, the data is processed; otherwise, it returns an error.
func (m *Match) EnsureMatchWithData(signature any, data []byte) error {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think Required or just Require versus Ensure. Ensure sounds like if it fails to do so, it will then do something to make it happen.

Sorry I know both me and gk have tagged you a lot about word choices 😅

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

🤷 I obviously don't know how to word so it's not surprising.

exchanges/stream/websocket_connection.go Show resolved Hide resolved
}

return json.Unmarshal(inbound.Data, &to)
return json.Unmarshal(inbound.Data, &funnelResult{Result: result})
Copy link
Collaborator

Choose a reason for hiding this comment

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

Something for another time is that I think jsonparser may be of use in the

if err := json.Unmarshal(endResponse, &inbound); err != nil {

above this. All you do is check a status and then if failed, the error message. Might be able to save on a double unmarshal. But Sonic the json hedgehog might be faster I can't benchmark that

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah good point; I will do some tests on it when I get some time, from what I have seen previously its still lighter to unmarshal everything using sonic rather than even json parser for one item. But mem bad 🤯. Also it might add in overhead from a non error path situation if we look at it from that perspective. We shall see.

@shazbert shazbert removed the test(s) fix This is to denote the PR is fixing a build test issue label Dec 12, 2024
@shazbert
Copy link
Collaborator Author

removed label because test fix was included in recent commit

@shazbert shazbert removed the nomerge requires dependency This pull request is dependent on another, so it can't be merged until the dependent one is merged label Dec 12, 2024
Copy link
Collaborator

@gloriousCode gloriousCode left a comment

Choose a reason for hiding this comment

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

tACK! Thanks Shazburtino

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
high priority review me This pull request is ready for review
Projects
Status: In review
Development

Successfully merging this pull request may close these issues.

3 participants