mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-10 12:25:02 +00:00
Add bail-out after too many 429 errors
This commit is contained in:
parent
101367a103
commit
3c96cad8c6
2 changed files with 33 additions and 1 deletions
21
backend/src/utils/DecayingCounter.ts
Normal file
21
backend/src/utils/DecayingCounter.ts
Normal file
|
@ -0,0 +1,21 @@
|
|||
/**
|
||||
* This is not related to Zeppelin's counters feature
|
||||
*/
|
||||
export class DecayingCounter {
|
||||
protected value = 0;
|
||||
|
||||
constructor(protected decayInterval: number) {
|
||||
setInterval(() => {
|
||||
this.value = Math.max(0, this.value - 1);
|
||||
}, decayInterval);
|
||||
}
|
||||
|
||||
add(count = 1): number {
|
||||
this.value += count;
|
||||
return this.value;
|
||||
}
|
||||
|
||||
get(): number {
|
||||
return this.value;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue