From f27b7a750f1876632e84d594608d3d64ce974efc Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 17 Jun 2022 14:08:13 +0200 Subject: Send views in a dedicated queue --- server/lib/activitypub/send/send-view.ts | 2 +- server/lib/activitypub/send/shared/send-utils.ts | 19 +++++++++++++++---- 2 files changed, 16 insertions(+), 5 deletions(-) (limited to 'server/lib/activitypub') diff --git a/server/lib/activitypub/send/send-view.ts b/server/lib/activitypub/send/send-view.ts index 25a20ec6d..bf3451603 100644 --- a/server/lib/activitypub/send/send-view.ts +++ b/server/lib/activitypub/send/send-view.ts @@ -26,7 +26,7 @@ async function sendView (options: { return buildViewActivity({ url, byActor, video, audience, type }) } - return sendVideoRelatedActivity(activityBuilder, { byActor, video, transaction, contextType: 'View' }) + return sendVideoRelatedActivity(activityBuilder, { byActor, video, transaction, contextType: 'View', parallelizable: true }) } // --------------------------------------------------------------------------- diff --git a/server/lib/activitypub/send/shared/send-utils.ts b/server/lib/activitypub/send/shared/send-utils.ts index 72368c762..fcec63991 100644 --- a/server/lib/activitypub/send/shared/send-utils.ts +++ b/server/lib/activitypub/send/shared/send-utils.ts @@ -15,9 +15,10 @@ async function sendVideoRelatedActivity (activityBuilder: (audience: ActivityAud byActor: MActorLight video: MVideoImmutable | MVideoAccountLight contextType: ContextType + parallelizable?: boolean transaction?: Transaction }) { - const { byActor, video, transaction, contextType } = options + const { byActor, video, transaction, contextType, parallelizable } = options // Send to origin if (video.isOwned() === false) { @@ -38,6 +39,7 @@ async function sendVideoRelatedActivity (activityBuilder: (audience: ActivityAud toFollowersOf: actorsInvolvedInVideo, transaction, actorsException, + parallelizable, contextType }) } @@ -130,9 +132,10 @@ async function broadcastToFollowers (options: { transaction: Transaction contextType: ContextType + parallelizable?: boolean actorsException?: MActorWithInboxes[] }) { - const { data, byActor, toFollowersOf, transaction, contextType, actorsException = [] } = options + const { data, byActor, toFollowersOf, transaction, contextType, actorsException = [], parallelizable } = options const uris = await computeFollowerUris(toFollowersOf, actorsException, transaction) @@ -141,6 +144,7 @@ async function broadcastToFollowers (options: { uris, data, byActor, + parallelizable, contextType }) }) @@ -173,8 +177,9 @@ function broadcastTo (options: { data: any byActor: MActorId contextType: ContextType + parallelizable?: boolean // default to false }) { - const { uris, data, byActor, contextType } = options + const { uris, data, byActor, contextType, parallelizable } = options if (uris.length === 0) return undefined @@ -200,7 +205,13 @@ function broadcastTo (options: { contextType } - JobQueue.Instance.createJob({ type: 'activitypub-http-broadcast', payload }) + JobQueue.Instance.createJob({ + type: parallelizable + ? 'activitypub-http-broadcast-parallel' + : 'activitypub-http-broadcast', + + payload + }) } for (const unicastUri of unicastUris) { -- cgit v1.2.3