[state]: watchers return a state
This commit is contained in:
@@ -17,6 +17,7 @@ export interface ConfWS2P {
|
||||
}
|
||||
|
||||
export interface ConfURL {
|
||||
name: string
|
||||
address: string
|
||||
frequency: number
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user