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

exchanges/request: abstract and consolidate rate limiting code to request package #1477

Merged
merged 19 commits into from
Jun 3, 2024

Conversation

shazbert
Copy link
Collaborator

@shazbert shazbert commented Feb 13, 2024

PR Description

Pulled from initial draft #1151

  • Allows context cancellation to occur while routine is being rate limited for any outbound REST request
  • Reduces wrapper code size and bespoke implementations
  • Fixes a couple of endpoints defaulting to unauth rates [BUG]

Type of change

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 shazbert added the review me This pull request is ready for review label Feb 13, 2024
@shazbert shazbert requested a review from a team February 13, 2024 00:10
@shazbert shazbert self-assigned this Feb 13, 2024
@shazbert shazbert added the reconstructing Based on PR feedback, this is currently being reworked and is not to be merged label Apr 30, 2024
@shazbert shazbert removed the reconstructing Based on PR feedback, this is currently being reworked and is not to be merged label May 1, 2024
@shazbert shazbert requested a review from gloriousCode May 1, 2024 00:15
@shazbert shazbert added the bug label May 1, 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.

Cool! Only basic things that I could see.

exchanges/request/limit.go Outdated Show resolved Hide resolved
exchanges/binance/ratelimit.go Outdated Show resolved Hide resolved
exchanges/binance/ratelimit.go Outdated Show resolved Hide resolved
exchanges/bybit/ratelimit.go Outdated Show resolved Hide resolved
exchanges/request/limit.go Outdated Show resolved Hide resolved
exchanges/request/limit.go Outdated Show resolved Hide resolved
@shazbert shazbert requested a review from gloriousCode May 1, 2024 05:14
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.

Thanks for making those changes!

exchanges/bitfinex/ratelimit.go Outdated Show resolved Hide resolved
exchanges/binance/ratelimit_test.go Show resolved Hide resolved
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! rate limiter still functioning
image
(rate limit at 1.991s with all pairs enabled)

@gloriousCode gloriousCode added the gcrc GloriousCode Review Complete label May 7, 2024
Copy link

codecov bot commented May 15, 2024

Codecov Report

Attention: Patch coverage is 95.55215% with 29 lines in your changes are missing coverage. Please review.

Project coverage is 35.97%. Comparing base (c37a115) to head (e4ca46c).
Report is 1 commits behind head on master.

Current head e4ca46c differs from pull request most recent head b17621b

Please upload reports for the commit b17621b to get more accurate results.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1477      +/-   ##
==========================================
- Coverage   37.78%   35.97%   -1.82%     
==========================================
  Files         409      409              
  Lines      147697   176414   +28717     
==========================================
+ Hits        55807    63464    +7657     
- Misses      84031   105101   +21070     
+ Partials     7859     7849      -10     
Files Coverage Δ
currency/coinmarketcap/coinmarketcap.go 55.33% <100.00%> (-1.01%) ⬇️
exchanges/binance/binance_cfutures.go 33.55% <100.00%> (-5.77%) ⬇️
exchanges/binance/binance_wrapper.go 38.45% <100.00%> (-2.82%) ⬇️
exchanges/binance/ratelimit.go 96.51% <100.00%> (+31.89%) ⬆️
exchanges/binance/type_convert.go 56.36% <ø> (-1.29%) ⬇️
exchanges/binanceus/binanceus_wrapper.go 40.89% <100.00%> (-4.00%) ⬇️
exchanges/binanceus/ratelimit.go 84.84% <100.00%> (+36.63%) ⬆️
exchanges/bitfinex/bitfinex_wrapper.go 37.95% <100.00%> (-3.57%) ⬇️
exchanges/bitfinex/ratelimit.go 100.00% <100.00%> (+54.79%) ⬆️
exchanges/bitflyer/bitflyer.go 50.31% <100.00%> (-10.52%) ⬇️
... and 47 more

... and 331 files with indirect coverage changes

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 deribit changes

Copy link
Collaborator

@thrasher- thrasher- left a comment

Choose a reason for hiding this comment

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

Great stuff @shazbert

@thrasher- thrasher- merged commit f6a95da into thrasher-corp:master Jun 3, 2024
5 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug gcrc GloriousCode Review Complete high priority review me This pull request is ready for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants