Use config.ts for state TTL

This commit is contained in:
projectmoon 2023-03-22 15:14:13 +01:00
parent 52583c4e32
commit 56dc20abff
2 changed files with 4 additions and 5 deletions

View File

@ -1,3 +1,3 @@
export default {
StateTTL: 5 * 60 * 1000
StateTTL: 0.25 * 60 * 1000
}

View File

@ -1,7 +1,6 @@
import { Level } from 'level';
import { ExporterState, PartialStateUpdate, Status } from './index';
const FIVE_MINUTES = 0.25 * 60 * 1000;
import Config from '../config';
type LevelError = Error | null | undefined;
@ -43,8 +42,8 @@ class LevelState {
}
private async prepTTL() {
console.info("Will clear state in 5 minutes");
this.currentTTLHandle = window.setTimeout(async () => await this.clear(), FIVE_MINUTES);
console.info(`Will clear state in ${Config.StateTTL} milliseconds`);
this.currentTTLHandle = window.setTimeout(async () => await this.clear(), Config.StateTTL);
}
async update(stateUpdate: ExporterState | PartialStateUpdate): Promise<ExporterState> {