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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add concurrency to GetUSD #766

Merged
merged 4 commits into from Feb 13, 2023
Merged

Add concurrency to GetUSD #766

merged 4 commits into from Feb 13, 2023

Conversation

aniketsingh03
Copy link
Contributor

Changes

  • This PR adds concurrency in fetching the USD value of a token from multiple data providers (coinmarketcap, coingecko, etc)

Fixes

Tests

Tasks to complete before merging PR:

  • Ensure system tests are passing. If not Run them manually to check for any regressions 馃搵
  • Do any new system tests need added to test this change? do any existing system tests need updated? If so create a PR at 0chain/system_test
  • Merge your system tests PR to master AFTER merging this PR

Associated PRs (Link as appropriate):

  • blobber:
  • 0chain:
  • system_test:
  • zboxcli:
  • zwalletcli:
  • Other: ...

errs = append(errs, e)
mu.Unlock()
if len(errs) >= len(quotes) {
finalErrCh <- fmt.Errorf("%w: %s", ErrNoAvailableQuoteQuery, errs)
Copy link
Member

Choose a reason for hiding this comment

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

only one message will be read from this channel, other routines with error will hang forever on write, since nobody will read msg. you need to create buffer for len(quotes) elements or create wait group to wait for all the tasks to finish

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for pointing out. I have made it simpler now. There was no need of second goroutine apparently, as it wasn't helping in anyway. Pls have another look and let me know.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also, there wasn't a need to listen for ctx.Done because of the way resty is designed. It returnes immediately after the parent context's deadline exceeds.

Copy link
Member

@peterlimg peterlimg left a comment

Choose a reason for hiding this comment

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

LGTM

@peterlimg
Copy link
Member

The failed test case is not related to the PR changes, so mark it as pass.

@service-0chain
Copy link
Contributor

Manual system tests [success] with the following config

config value
tests skipped TRUE
system-tests master
gosdk performance/getUSD
zboxcli staging
zwalletcli staging
0chain staging
blobber staging
authorizer staging
0box staging
0block staging
0dns staging
explorer staging
0proxy staging
0search staging

@peterlimg peterlimg merged commit 76ccfaa into staging Feb 13, 2023
@peterlimg peterlimg deleted the performance/getUSD branch February 13, 2023 03:11
@aniketsingh03
Copy link
Contributor Author

Thanks @peterlimg

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

Successfully merging this pull request may close these issues.

Improve GetUSD to fetch data from all providers concurrently
4 participants