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

feat(price-feeder): Convert remaining providers to the Websocket Controller #1554

Merged
merged 37 commits into from
Nov 9, 2022

Conversation

zarazan
Copy link
Contributor

@zarazan zarazan commented Nov 7, 2022

Description

Converted the remaining providers over to use the Websocket Controller. For each provider I cross referenced the current API docs with how we currently handle their websocket and tuned it to maintain a stable connection.

Changes other than just converting providers to use the Controller:

  • Coinbase: Added a ping loop to keep the connection alive longer
  • Crypto.com: Changed the pricing info to parse into strings instead of float to correctly read prices
  • Huobi: Add the HuobiSubscriptionResp to handle subscription response messages and prevent an erroneous error
  • Added a second context to the WebsocketController to kill the old ping loop after a reconnect happens. Otherwise we risk running multiple ping loops for a single provider.
  • Added an integration test that tests creating an active connection, receiving and parsing prices for each provider websocket we have implemented.

closes: #1507


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title
  • added ! to the type prefix if API or client breaking change
  • added appropriate labels to the PR
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • added a changelog entry to CHANGELOG.md
  • included comments for documenting Go code
  • updated the relevant documentation or specification
  • reviewed "Files changed" and left comments if necessary
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic
  • reviewed API design and naming
  • reviewed documentation is accurate
  • reviewed tests and test coverage
  • manually tested (if applicable)

@zarazan zarazan changed the title chore chore(price-feeder): Convert remaining providers over to use the Websocket Controller Nov 7, 2022
@zarazan zarazan force-pushed the zarazan/websocket-controller branch from b15e1ca to 132d95e Compare November 7, 2022 20:03
@zarazan zarazan changed the title chore(price-feeder): Convert remaining providers over to use the Websocket Controller chore(price-feeder): Convert remaining providers to the Websocket Controller Nov 7, 2022
@zarazan zarazan marked this pull request as ready for review November 7, 2022 21:04
@zarazan zarazan requested a review from a team as a code owner November 7, 2022 21:04
@robert-zaremba robert-zaremba changed the title chore(price-feeder): Convert remaining providers to the Websocket Controller feat(price-feeder): Convert remaining providers to the Websocket Controller Nov 7, 2022
@adamewozniak
Copy link
Collaborator

woo! Checking this out @zarazan

@zarazan zarazan requested a review from adamewozniak November 7, 2022 22:53
Copy link
Collaborator

@adamewozniak adamewozniak left a comment

Choose a reason for hiding this comment

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

looks good! just need tests to pass.

would like another review, maybe from @rbajollari / @RafilxTenfen before we merge this in

@adamewozniak
Copy link
Collaborator

oh, and changelog please!

@RafilxTenfen
Copy link
Contributor

With this implementation, peggo cannot update the price-feeder version anymore, basically peggo does not know which prices will have to query when instantiating new providers. The new tickers might appear when someone tries to cross a different token

Or maybe every time a new price comes, we would need to kill the providers and instantiate again

@RafilxTenfen
Copy link
Contributor

this is so much cleaner than it was before, but thinking of price-feeder as a package for others, would be good to have an func to subscribe new pairs as needed with the provider running

@adamewozniak
Copy link
Collaborator

this is so much cleaner than it was before, but thinking of price-feeder as a package for others, would be good to have an func to subscribe new pairs as needed with the provider running

cc @zarazan

@adamewozniak
Copy link
Collaborator

@zarazan please lmk once rafael's concerns are addressed 🚀

Copy link
Collaborator

@adamewozniak adamewozniak left a comment

Choose a reason for hiding this comment

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

this looks good to me, might want another review from @RafilxTenfen

Copy link
Contributor

@RafilxTenfen RafilxTenfen left a comment

Choose a reason for hiding this comment

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

💯

@zarazan zarazan merged commit 6309e5c into main Nov 9, 2022
@zarazan zarazan deleted the zarazan/websocket-controller branch November 9, 2022 22:06
@toteki
Copy link
Member

toteki commented Nov 10, 2022

Do these need to be backported for price feeder v1 branch or is it all v2 stuff?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Convert the rest of the provider to use the WebsocketController
5 participants