@voicenter-team/mysql-dynamic-cluster
Version:
Galera cluster with implementation of dynamic choose mysql server for queries, caching, hashing it and metrics
42 lines • 933 B
JavaScript
;
/**
* Created by Bohdan on Sep, 2021
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.Timer = void 0;
/**
* Simple timer what call callback some period of time
*/
class Timer {
/**
* @param callback callback what called when time is out
*/
constructor(callback) {
this._active = false;
this._callback = callback;
this._timer = null;
this._active = true;
}
get active() {
return this._active;
}
/**
* Run timer
* @param time time how much need to wait
*/
start(time) {
if (!this._active)
return;
this._timer = setTimeout(this._callback, time);
}
/**
* Clear timer and stop it
*/
dispose() {
clearTimeout(this._timer);
this._timer = null;
this._active = false;
}
}
exports.Timer = Timer;
//# sourceMappingURL=Timer.js.map