[state]: watchers return a state

This commit is contained in:
2020-04-30 15:19:58 +02:00
parent 6d43cbc725
commit f0a98ba685
11 changed files with 57 additions and 22 deletions

View File

@@ -17,6 +17,7 @@ export interface ConfWS2P {
}
export interface ConfURL {
name: string
address: string
frequency: number
}

View File

@@ -1,3 +1,21 @@
export interface ServiceState {
state: 'INIT'|'OK'|'FAILURE'
}
export class Watcher {
private state: 'INIT'|'OK'|'FAILURE'|'RECOVERED'
private failureMessage?: string
constructor(public readonly name: string) {
this.state = "INIT"
}
public stateOK() {
this.state = "OK"
}
public stateRecovered() {
this.state = "RECOVERED"
}
public stateFailure(error: string) {
this.state = "FAILURE"
this.failureMessage = error
}
}