From 5839ad4f5e91708b60c539d896d66a6bf9addcb3 Mon Sep 17 00:00:00 2001 From: anatawa12 Date: Sun, 16 Jun 2024 22:11:10 +0900 Subject: [PATCH] =?UTF-8?q?chore(backend):=20VRTL=E5=8F=82=E5=8A=A0?= =?UTF-8?q?=E3=82=B5=E3=83=BC=E3=83=90=E3=83=BC=E3=81=AE=E5=8F=96=E5=BE=97?= =?UTF-8?q?=E3=81=AB=E5=A4=B1=E6=95=97=E3=81=97=E3=81=9F=E3=81=A8=E3=81=8D?= =?UTF-8?q?=E3=81=AE=E3=83=AA=E3=83=88=E3=83=A9=E3=82=A4=E3=81=AE=E9=96=93?= =?UTF-8?q?=E9=9A=94=E3=82=92=E7=9F=AD=E3=81=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG-VRTL.md | 1 + .../backend/src/core/VmimiRelayTimelineService.ts | 13 +++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/CHANGELOG-VRTL.md b/CHANGELOG-VRTL.md index 7c3dc085ce6a..fdbe020749ba 100644 --- a/CHANGELOG-VRTL.md +++ b/CHANGELOG-VRTL.md @@ -3,6 +3,7 @@ VRTLのブランチで行われた変更点をまとめています +- chore(backend): VRTL参加サーバーの取得に失敗したときのリトライの間隔を短く - feat: VRTL/VSTLに連合なし投稿を含めるかを選択可能に - もともとのVRTL/VSTLでは連合なし投稿が常に含まれていましたが、正しくVRTL/VSTLのノートを表現するために含めないようにできるようになりました - VSTLの場合、連合なし投稿を含めないようにしてもフォローしている人の連合なし投稿は表示されます diff --git a/packages/backend/src/core/VmimiRelayTimelineService.ts b/packages/backend/src/core/VmimiRelayTimelineService.ts index 6dd9c5efcaa6..a5f1b43699cc 100644 --- a/packages/backend/src/core/VmimiRelayTimelineService.ts +++ b/packages/backend/src/core/VmimiRelayTimelineService.ts @@ -13,14 +13,16 @@ import type Logger from '@/logger.js'; type VmimiInstanceList = { Url: string; }[]; // one day -const UpdateInterval = 1000 * 60 * 60 * 24; -const RetryInterval = 1000 * 60 * 60 * 6; +const UpdateInterval = 1000 * 60 * 60 * 24; // 24 hours = 1 day +const MinRetryInterval = 1000 * 60; // one minutes +const MaxRetryInterval = 1000 * 60 * 60 * 6; // 6 hours @Injectable() export class VmimiRelayTimelineService { instanceHosts: Set; instanceHostsArray: string[]; nextUpdate: number; + nextRetryInterval: number; updatePromise: Promise | null; private logger: Logger; @@ -32,6 +34,7 @@ export class VmimiRelayTimelineService { this.instanceHosts = new Set([]); this.instanceHostsArray = []; this.nextUpdate = 0; + this.nextRetryInterval = MinRetryInterval; this.updatePromise = null; this.logger = this.loggerService.getLogger('vmimi'); @@ -55,10 +58,12 @@ export class VmimiRelayTimelineService { this.instanceHosts = new Set(this.instanceHostsArray); this.nextUpdate = Date.now() + UpdateInterval; this.logger.info(`Got instance list: ${this.instanceHostsArray}`); + this.nextRetryInterval = MinRetryInterval; } catch (e) { this.logger.error('Failed to update instance list', e as any); - this.nextUpdate = Date.now() + RetryInterval; - setTimeout(() => this.checkForUpdateInstanceList(), RetryInterval + 5); + this.nextUpdate = Date.now() + this.nextRetryInterval; + setTimeout(() => this.checkForUpdateInstanceList(), this.nextRetryInterval + 5); + this.nextRetryInterval = Math.min(this.nextRetryInterval * 2, MaxRetryInterval); } }