2020-01-09 05:24:45 +00:00
|
|
|
package wsutil
|
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"golang.org/x/time/rate"
|
|
|
|
)
|
|
|
|
|
|
|
|
func NewSendLimiter() *rate.Limiter {
|
2020-07-15 01:47:15 +00:00
|
|
|
return rate.NewLimiter(rate.Every(time.Minute), 120)
|
2020-01-09 05:24:45 +00:00
|
|
|
}
|
2020-01-15 04:43:34 +00:00
|
|
|
|
|
|
|
func NewDialLimiter() *rate.Limiter {
|
|
|
|
return rate.NewLimiter(rate.Every(5*time.Second), 1)
|
|
|
|
}
|
2020-01-15 07:34:18 +00:00
|
|
|
|
|
|
|
func NewIdentityLimiter() *rate.Limiter {
|
|
|
|
return NewDialLimiter() // same
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewGlobalIdentityLimiter() *rate.Limiter {
|
|
|
|
return rate.NewLimiter(rate.Every(24*time.Hour), 1000)
|
|
|
|
}
|