mirror of
				https://github.com/binwiederhier/ntfy.git
				synced 2025-10-31 21:12:36 +01:00 
			
		
		
		
	Reset message limiter, test
This commit is contained in:
		
							parent
							
								
									810a29ea72
								
							
						
					
					
						commit
						22c66203a0
					
				
					 3 changed files with 59 additions and 15 deletions
				
			
		|  | @ -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 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 binwiederhier
						binwiederhier