1
0
Fork 0
mirror of https://github.com/binwiederhier/ntfy.git synced 2025-05-25 00:07:36 +02:00

Reset message limiter, test

This commit is contained in:
binwiederhier 2023-01-27 09:42:54 -05:00
parent 810a29ea72
commit 22c66203a0
3 changed files with 59 additions and 15 deletions

View file

@ -50,6 +50,20 @@ func (l *FixedLimiter) Allow(n int64) error {
return nil
}
// Value returns the current limiter value
func (l *FixedLimiter) Value() int64 {
l.mu.Lock()
defer l.mu.Unlock()
return l.value
}
// Reset sets the limiter's value back to zero
func (l *FixedLimiter) Reset() {
l.mu.Lock()
defer l.mu.Unlock()
l.value = 0
}
// RateLimiter is a Limiter that wraps a rate.Limiter, allowing a floating time-based limit.
type RateLimiter struct {
limiter *rate.Limiter