[mod] e-mails plus explicites (titre + motif erreur)
This commit is contained in:
@@ -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`)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user