mirror of
https://github.com/kataras/iris.git
synced 2026-03-06 16:35:57 +00:00
improvements to the x/client package
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
package client
|
||||
|
||||
import "time"
|
||||
import (
|
||||
"time"
|
||||
|
||||
"golang.org/x/time/rate"
|
||||
)
|
||||
|
||||
// All the builtin client options should live here, for easy discovery.
|
||||
|
||||
@@ -33,3 +37,12 @@ func PersistentRequestOptions(reqOpts ...RequestOption) Option {
|
||||
c.PersistentRequestOptions = append(c.PersistentRequestOptions, reqOpts...)
|
||||
}
|
||||
}
|
||||
|
||||
// RateLimit configures the rate limit for requests.
|
||||
//
|
||||
// Defaults to zero which disables rate limiting.
|
||||
func RateLimit(requestsPerSecond int) Option {
|
||||
return func(c *Client) {
|
||||
c.rateLimiter = rate.NewLimiter(rate.Limit(requestsPerSecond), requestsPerSecond)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user