feat: #6533 salix class to handle salix calls
This commit is contained in:
parent
2bb99bf093
commit
ac21ae5b92
|
@ -0,0 +1,43 @@
|
||||||
|
module.exports = class Salix {
|
||||||
|
constructor() {
|
||||||
|
this.conf = null;
|
||||||
|
this._logInfo = [];
|
||||||
|
this._salixVersion = null;
|
||||||
|
}
|
||||||
|
async init(logger) {
|
||||||
|
|
||||||
|
this.conf = logger.conf;
|
||||||
|
|
||||||
|
setInterval(() => this.getSalixVersion, this.conf.salix.renewInterval);
|
||||||
|
await this.salixLogInfo();
|
||||||
|
}
|
||||||
|
|
||||||
|
async getSalixVersion(){
|
||||||
|
console.log("SALIX - CHECK VERSION");
|
||||||
|
let salixCall = await fetch(`${this.conf.salix.url}/applications/version`, {
|
||||||
|
method: "GET",
|
||||||
|
});
|
||||||
|
let salixVersion = JSON.parse(await salixCall.text());
|
||||||
|
console.log("SALIX - VERSION CHECKED");
|
||||||
|
if(this._salixVersion !== salixVersion) fetch();
|
||||||
|
}
|
||||||
|
|
||||||
|
async salixLogInfo() {
|
||||||
|
console.log("SALIX - LOGINFO REQUEST");
|
||||||
|
let salixCall = await fetch(`${this.conf.salix.url}/schemas/logInfo`, {
|
||||||
|
method: "GET",
|
||||||
|
});
|
||||||
|
let salixLogConfig = [JSON.parse(await salixCall.text())];
|
||||||
|
this._salixVersion = salixCall.headers.get("Salix-version");
|
||||||
|
this._logInfo = salixLogConfig
|
||||||
|
console.log("SALIX- LOGINFO REQUESTED");
|
||||||
|
}
|
||||||
|
|
||||||
|
get logInfo(){
|
||||||
|
return this._logInfo
|
||||||
|
}
|
||||||
|
|
||||||
|
get salixVersion(){
|
||||||
|
return this._salixVersion;
|
||||||
|
}
|
||||||
|
};
|
Loading…
Reference in New Issue