Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ReqConfig ¶
type ReqConfig struct {
// contains filtered or unexported fields
}
ReqConfig control the reqlimit general configuration
func New ¶
func New(attrs ...interface{}) *ReqConfig
New create a new ReqLimiter Use it like this: New(namespace, redisHost, redisPass, redisPoolCount) namespace: namespace for redis key (optional, default empty) redisHost: redis host and port (optional, default localhost:6379) redisPass: redis password (optional, default empty) redisPoolCount: number of pool for redis connection (optional, default 5)
func (*ReqConfig) Close ¶
func (rc *ReqConfig) Close()
Close close the connection use by reqlimiter, you must call this close after you done using req limiter
func (*ReqConfig) NewLimiter ¶
func (rc *ReqConfig) NewLimiter(name string, interval int, limit int) *ReqLimiter
NewLimiter create request limiter for limit/interval (ex 20/second) interval must be in second you can make more than one limiter but name of limiter must be unique if there is duplicate in names, it will panic
type ReqLimiter ¶
type ReqLimiter struct {
// contains filtered or unexported fields
}
ReqLimiter limit how many request can be made per interval Duration