From 9db437c8155f3563a33e22ed2896072a9f1fbdb0 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 13 Oct 2021 11:47:32 +0200 Subject: Process slow followers in unicast job queue --- server/lib/files-cache/actor-follow-score-cache.ts | 75 ---------------------- server/lib/files-cache/index.ts | 2 +- 2 files changed, 1 insertion(+), 76 deletions(-) delete mode 100644 server/lib/files-cache/actor-follow-score-cache.ts (limited to 'server/lib/files-cache') diff --git a/server/lib/files-cache/actor-follow-score-cache.ts b/server/lib/files-cache/actor-follow-score-cache.ts deleted file mode 100644 index 465080e72..000000000 --- a/server/lib/files-cache/actor-follow-score-cache.ts +++ /dev/null @@ -1,75 +0,0 @@ -import { ACTOR_FOLLOW_SCORE } from '../../initializers/constants' -import { logger } from '../../helpers/logger' - -// Cache follows scores, instead of writing them too often in database -// Keep data in memory, we don't really need Redis here as we don't really care to loose some scores -class ActorFollowScoreCache { - - private static instance: ActorFollowScoreCache - private pendingFollowsScore: { [ url: string ]: number } = {} - private pendingBadServer = new Set() - private pendingGoodServer = new Set() - - private constructor () {} - - static get Instance () { - return this.instance || (this.instance = new this()) - } - - updateActorFollowsScore (goodInboxes: string[], badInboxes: string[]) { - if (goodInboxes.length === 0 && badInboxes.length === 0) return - - logger.info( - 'Updating %d good actor follows and %d bad actor follows scores in cache.', - goodInboxes.length, badInboxes.length, { badInboxes } - ) - - for (const goodInbox of goodInboxes) { - if (this.pendingFollowsScore[goodInbox] === undefined) this.pendingFollowsScore[goodInbox] = 0 - - this.pendingFollowsScore[goodInbox] += ACTOR_FOLLOW_SCORE.BONUS - } - - for (const badInbox of badInboxes) { - if (this.pendingFollowsScore[badInbox] === undefined) this.pendingFollowsScore[badInbox] = 0 - - this.pendingFollowsScore[badInbox] += ACTOR_FOLLOW_SCORE.PENALTY - } - } - - addBadServerId (serverId: number) { - this.pendingBadServer.add(serverId) - } - - getBadFollowingServerIds () { - return Array.from(this.pendingBadServer) - } - - clearBadFollowingServerIds () { - this.pendingBadServer = new Set() - } - - addGoodServerId (serverId: number) { - this.pendingGoodServer.add(serverId) - } - - getGoodFollowingServerIds () { - return Array.from(this.pendingGoodServer) - } - - clearGoodFollowingServerIds () { - this.pendingGoodServer = new Set() - } - - getPendingFollowsScore () { - return this.pendingFollowsScore - } - - clearPendingFollowsScore () { - this.pendingFollowsScore = {} - } -} - -export { - ActorFollowScoreCache -} diff --git a/server/lib/files-cache/index.ts b/server/lib/files-cache/index.ts index e921d04a7..e5853f7d6 100644 --- a/server/lib/files-cache/index.ts +++ b/server/lib/files-cache/index.ts @@ -1,3 +1,3 @@ -export * from './actor-follow-score-cache' export * from './videos-preview-cache' export * from './videos-caption-cache' +export * from './videos-torrent-cache' -- cgit v1.2.3