[mod] recall of FAILURE state periodically

This commit is contained in:
2020-05-08 11:40:25 +02:00
parent 9ebf9d94fe
commit 4bed33d66f
8 changed files with 43 additions and 22 deletions

View File

@@ -5,13 +5,14 @@ export function watcherLoop(
connect: () => Promise<void>,
onConnectionClosed: () => Promise<void>,
waitingDelay: number,
recallDelay: number,
onStart: () => Promise<void>,
onDisconnection: (waitingDelay: number, error: any) => Promise<void>,
onDisconnection: (waitingDelay: number, recallDelay: number, error: any) => Promise<void>,
onRestart: () => Promise<void>,
onRestartSuccess: () => Promise<void>,
): Watcher {
let watcher: Watcher = new Watcher(name)
let watcher: Watcher = new Watcher(name, recallDelay)
let hasStarted = false
;(async () => {
@@ -48,7 +49,7 @@ export function watcherLoop(
// Wait before reconnecting
if (watcher.stateChanged) {
// Notify only if state changed since
await onDisconnection(waitingDelay, watcher.error)
await onDisconnection(waitingDelay, recallDelay, watcher.error)
}
await new Promise(resolve => setTimeout(resolve, waitingDelay))
i++