Доработки отправки bookUrls

This commit is contained in:
Book Pauk
2022-07-27 20:50:39 +07:00
parent 0067c2800a
commit 7ca8fd9ca1

View File

@@ -26,10 +26,12 @@ class BUCClient {
//константы //константы
if (this.config.branch !== 'development') { if (this.config.branch !== 'development') {
this.cleanQueryInterval = 300*dayMs;//интервал очистки устаревших this.cleanQueryInterval = 300*dayMs;//интервал очистки устаревших
this.syncPeriod = 1*minuteMs;//1*hourMs;//период синхронизации с сервером BUC this.syncPeriod = 1*hourMs;//период синхронизации с сервером BUC
this.sendBookUrlsPeriod = 1*minuteMs;//период отправки BookUrls на сервер BUC
} else { } else {
this.cleanQueryInterval = 300*dayMs;//интервал очистки устаревших this.cleanQueryInterval = 300*dayMs;//интервал очистки устаревших
this.syncPeriod = 1*minuteMs;//период синхронизации с сервером BUC this.syncPeriod = 1*minuteMs;//период синхронизации с сервером BUC
this.sendBookUrlsPeriod = 1*1000;//период отправки BookUrls на сервер BUC
} }
this.fromCheckTime = 1; this.fromCheckTime = 1;
@@ -118,12 +120,11 @@ class BUCClient {
return result; return result;
} }
async periodicSync() { async periodicSendBookUrls() {
const db = this.appDb;
while (1) {//eslint-disable-line while (1) {//eslint-disable-line
try { try {
//сначала отправим this.bookUrls //отправим this.bookUrls
if (this.bookUrls.size) {
log(`client: remote update buc begin`); log(`client: remote update buc begin`);
const arr = Array.from(this.bookUrls); const arr = Array.from(this.bookUrls);
@@ -146,7 +147,20 @@ class BUCClient {
} }
} }
log(`client: remote update buc end, updated ${updated} urls`); log(`client: remote update buc end, updated ${updated} urls`);
}
} catch (e) {
log(LM_ERR, e.stack);
}
await utils.sleep(this.sendBookUrlsPeriod);
}
}
async periodicSync() {
const db = this.appDb;
while (1) {//eslint-disable-line
try {
//почистим нашу таблицу 'buc' //почистим нашу таблицу 'buc'
log(`client: clean 'buc' table begin`); log(`client: clean 'buc' table begin`);
const cleanTime = Date.now() - this.cleanQueryInterval; const cleanTime = Date.now() - this.cleanQueryInterval;
@@ -232,6 +246,7 @@ class BUCClient {
this.fromCheckTime = await this.findMaxCheckTime(); this.fromCheckTime = await this.findMaxCheckTime();
this.periodicSendBookUrls();//no await
this.periodicSync();//no await this.periodicSync();//no await
log(`BUC Client started`); log(`BUC Client started`);