[mod] e-mails plus explicites (titre + motif erreur)

This commit is contained in:
2020-05-08 11:03:00 +02:00
parent 2be3471067
commit f3b50c4fea
10 changed files with 110 additions and 69 deletions

View File

@@ -1,11 +1,12 @@
import {Conf, ConfWWMeta} from "../../types/conf";
import {urlWatcher} from '../abstract/url-watcher'
import {urlWatcher, UrlWatcherResult} from '../abstract/url-watcher'
function handleLateness(confHead: ConfWWMeta, data: WWMetaJson) {
const diff = Math.round(Date.now()/1000 - data.now)
if (diff >= confHead.maxLate) {
throw `WWMeta.json is late by ${diff}s (>= ${confHead.maxLate})`
return UrlWatcherResult.ko(`WWMeta.json is late by ${diff}s (>= ${confHead.maxLate})`)
}
return UrlWatcherResult.ok()
}
export function jsonWatcher(conf: Conf) {
@@ -15,12 +16,15 @@ export function jsonWatcher(conf: Conf) {
return async (confWWMeta: ConfWWMeta) => {
return urlWatcher(conf, async (data) => {
handleLateness(confWWMeta, data)
return handleLateness(confWWMeta, data)
})({
name: `WWMeta.json watcher ${confWWMeta.address}`,
address: confWWMeta.address + URL_PATH,
frequency: confWWMeta.frequency
})
},
() => `[OK] WWMeta.json is up-to-date`,
() => `[FAILURE] WWMeta.json`,
() => `[RECOVERED] WWMeta.json`)
}
}