3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-24 01:55:03 +00:00

Add bail-out after too many 429 errors

This commit is contained in:
Dragory 2021-08-18 23:57:44 +03:00
parent 836394d53e
commit 5bffe2fee5
2 changed files with 33 additions and 1 deletions

View 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;
}
}