Files
gocryptotrader/exchanges/request/options.go
Ryan O'Hara-Reid f6a95da536 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>
2024-06-03 11:57:31 +10:00

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
}
}