mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-14 15:09:51 +00:00
* 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>
30 lines
685 B
Go
30 lines
685 B
Go
package request
|
|
|
|
// WithBackoff configures the backoff strategy for a Requester.
|
|
func WithBackoff(b Backoff) RequesterOption {
|
|
return func(r *Requester) {
|
|
r.backoff = b
|
|
}
|
|
}
|
|
|
|
// WithLimiter configures the rate limiter for a Requester.
|
|
func WithLimiter(def RateLimitDefinitions) RequesterOption {
|
|
return func(r *Requester) {
|
|
r.limiter = def
|
|
}
|
|
}
|
|
|
|
// WithRetryPolicy configures the retry policy for a Requester.
|
|
func WithRetryPolicy(p RetryPolicy) RequesterOption {
|
|
return func(r *Requester) {
|
|
r.retryPolicy = p
|
|
}
|
|
}
|
|
|
|
// WithReporter configures the reporter for a Requester.
|
|
func WithReporter(rep Reporter) RequesterOption {
|
|
return func(r *Requester) {
|
|
r.reporter = rep
|
|
}
|
|
}
|