mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-06-04 15:10:54 +00:00
exchanges/request: abstract and consolidate rate limiting code to request package (#1477)
* initial consolidation of rate limiting code to request package to reduce bespoke code implementation * continued * finish abstraction * lint * exchanges: fix tests * linter: fix * poloniex: fix auth rate limit not being set * ratelimiter: convert from token to weight * glorious: nits addressed with fire * linter: rip * change func name set -> get * fix test * derbit: impl --------- Co-authored-by: Ryan O'Hara-Reid <ryan.oharareid@thrasher.io>
This commit is contained in:
@@ -1226,11 +1226,11 @@ func sendGetReq(path string, result interface{}) error {
|
||||
if strings.Contains(path, "github") {
|
||||
requester, err = request.New("Apichecker",
|
||||
common.NewHTTPClientWithTimeout(exchange.DefaultHTTPTimeout),
|
||||
request.WithLimiter(request.NewBasicRateLimit(time.Hour, 60)))
|
||||
request.WithLimiter(request.NewBasicRateLimit(time.Hour, 60, 1)))
|
||||
} else {
|
||||
requester, err = request.New("Apichecker",
|
||||
common.NewHTTPClientWithTimeout(exchange.DefaultHTTPTimeout),
|
||||
request.WithLimiter(request.NewBasicRateLimit(time.Second, 100)))
|
||||
request.WithLimiter(request.NewBasicRateLimit(time.Second, 100, 1)))
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -1249,7 +1249,7 @@ func sendGetReq(path string, result interface{}) error {
|
||||
func sendAuthReq(method, path string, result interface{}) error {
|
||||
requester, err := request.New("Apichecker",
|
||||
common.NewHTTPClientWithTimeout(exchange.DefaultHTTPTimeout),
|
||||
request.WithLimiter(request.NewBasicRateLimit(time.Second*10, 100)))
|
||||
request.WithLimiter(request.NewBasicRateLimit(time.Second*10, 100, 1)))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user