1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-04 18:29:27 +02:00

Process slow followers in unicast job queue

This commit is contained in:
Chocobozzz 2021-10-13 11:47:32 +02:00
parent e81f6ccf98
commit 9db437c815
No known key found for this signature in database
GPG key ID: 583A612D890159BE
10 changed files with 160 additions and 37 deletions

View file

@ -1,10 +1,10 @@
import { map } from 'bluebird'
import { Job } from 'bull'
import { ActorFollowHealthCache } from '@server/lib/actor-follow-health-cache'
import { ActivitypubHttpBroadcastPayload } from '@shared/models'
import { logger } from '../../../helpers/logger'
import { doRequest } from '../../../helpers/requests'
import { BROADCAST_CONCURRENCY } from '../../../initializers/constants'
import { ActorFollowScoreCache } from '../../files-cache'
import { buildGlobalHeaders, buildSignedRequestOptions, computeBody } from './utils/activitypub-http-utils'
async function processActivityPubHttpBroadcast (job: Job) {
@ -25,13 +25,17 @@ async function processActivityPubHttpBroadcast (job: Job) {
const badUrls: string[] = []
const goodUrls: string[] = []
await map(payload.uris, uri => {
return doRequest(uri, options)
.then(() => goodUrls.push(uri))
.catch(() => badUrls.push(uri))
await map(payload.uris, async uri => {
try {
await doRequest(uri, options)
goodUrls.push(uri)
} catch (err) {
logger.debug('HTTP broadcast to %s failed.', uri, { err })
badUrls.push(uri)
}
}, { concurrency: BROADCAST_CONCURRENCY })
return ActorFollowScoreCache.Instance.updateActorFollowsScore(goodUrls, badUrls)
return ActorFollowHealthCache.Instance.updateActorFollowsHealth(goodUrls, badUrls)
}
// ---------------------------------------------------------------------------