* Try to consume one token (hot path - in-memory only) * * @returns {boolean} True if request allowed, false if throttled
()
| 61 | * @returns {boolean} True if request allowed, false if throttled |
| 62 | */ |
| 63 | tryConsume() { |
| 64 | if (this.tokens > 0) { |
| 65 | this.tokens -= 1; |
| 66 | return true; // ALLOWED |
| 67 | } |
| 68 | |
| 69 | return false; // THROTTLED |
| 70 | } |
| 71 | |
| 72 | /** |
| 73 | * Check if refill is needed and trigger async refill |
no outgoing calls
no test coverage detected