Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type RateLimiter ¶
type RateLimiter struct {
// contains filtered or unexported fields
}
RateLimiter представляет собой структуру для ограничения частоты действий
func New ¶
func New(actionsPerDuration int, duration time.Duration) *RateLimiter
New creates new RateLimiter with given actions per duration minimum duration is 50millis = time.Millisecond * 50
func (*RateLimiter) Can ¶
func (rl *RateLimiter) Can() bool
can now take action or wait? true if now wait i.e. Wait() call will end immidiatelly
func (*RateLimiter) CanOrWait ¶ added in v0.0.4
func (rl *RateLimiter) CanOrWait() bool
= false if !Can() = true if can and already waited
func (*RateLimiter) Close ¶ added in v0.0.2
func (rl *RateLimiter) Close()
remove limiter from checking queue
func (*RateLimiter) Wait ¶
func (rl *RateLimiter) Wait()
Wait ожидает, пока действие станет возможным согласно ограничениям
Click to show internal directories.
Click to hide internal directories.