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:
parent
e81f6ccf98
commit
9db437c815
10 changed files with 160 additions and 37 deletions
|
@ -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)
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue