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 { export default {
StateTTL: 5 * 60 * 1000 StateTTL: 0.25 * 60 * 1000
} }

View File

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