aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/job-queue/handlers
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-05-09 09:08:22 +0200
committerChocobozzz <me@florianbigard.com>2018-05-09 09:08:22 +0200
commit71e3dfda4e2bcc228415c0d66b09a84bb73dddd1 (patch)
treef7b17a3f01b5e796b73debcd3f11fa0bb56f18bb /server/lib/job-queue/handlers
parent7797350a0e539b872bdcb59aa07fa9b16cb2db7a (diff)
downloadPeerTube-71e3dfda4e2bcc228415c0d66b09a84bb73dddd1.tar.gz
PeerTube-71e3dfda4e2bcc228415c0d66b09a84bb73dddd1.tar.zst
PeerTube-71e3dfda4e2bcc228415c0d66b09a84bb73dddd1.zip
Add timeout and TTL to request jobs
Diffstat (limited to 'server/lib/job-queue/handlers')
-rw-r--r--server/lib/job-queue/handlers/activitypub-http-broadcast.ts5
-rw-r--r--server/lib/job-queue/handlers/activitypub-http-fetcher.ts5
-rw-r--r--server/lib/job-queue/handlers/activitypub-http-unicast.ts4
3 files changed, 9 insertions, 5 deletions
diff --git a/server/lib/job-queue/handlers/activitypub-http-broadcast.ts b/server/lib/job-queue/handlers/activitypub-http-broadcast.ts
index 38b8393f4..d8b8ec222 100644
--- a/server/lib/job-queue/handlers/activitypub-http-broadcast.ts
+++ b/server/lib/job-queue/handlers/activitypub-http-broadcast.ts
@@ -4,7 +4,7 @@ import { logger } from '../../../helpers/logger'
4import { doRequest } from '../../../helpers/requests' 4import { doRequest } from '../../../helpers/requests'
5import { ActorFollowModel } from '../../../models/activitypub/actor-follow' 5import { ActorFollowModel } from '../../../models/activitypub/actor-follow'
6import { buildSignedRequestOptions, computeBody } from './utils/activitypub-http-utils' 6import { buildSignedRequestOptions, computeBody } from './utils/activitypub-http-utils'
7import { BROADCAST_CONCURRENCY } from '../../../initializers' 7import { BROADCAST_CONCURRENCY, JOB_REQUEST_TIMEOUT } from '../../../initializers'
8 8
9export type ActivitypubHttpBroadcastPayload = { 9export type ActivitypubHttpBroadcastPayload = {
10 uris: string[] 10 uris: string[]
@@ -24,7 +24,8 @@ async function processActivityPubHttpBroadcast (job: kue.Job) {
24 method: 'POST', 24 method: 'POST',
25 uri: '', 25 uri: '',
26 json: body, 26 json: body,
27 httpSignature: httpSignatureOptions 27 httpSignature: httpSignatureOptions,
28 timeout: JOB_REQUEST_TIMEOUT
28 } 29 }
29 30
30 const badUrls: string[] = [] 31 const badUrls: string[] = []
diff --git a/server/lib/job-queue/handlers/activitypub-http-fetcher.ts b/server/lib/job-queue/handlers/activitypub-http-fetcher.ts
index 062211c85..4683beb2f 100644
--- a/server/lib/job-queue/handlers/activitypub-http-fetcher.ts
+++ b/server/lib/job-queue/handlers/activitypub-http-fetcher.ts
@@ -1,7 +1,7 @@
1import * as kue from 'kue' 1import * as kue from 'kue'
2import { logger } from '../../../helpers/logger' 2import { logger } from '../../../helpers/logger'
3import { doRequest } from '../../../helpers/requests' 3import { doRequest } from '../../../helpers/requests'
4import { ACTIVITY_PUB } from '../../../initializers' 4import { ACTIVITY_PUB, JOB_REQUEST_TIMEOUT } from '../../../initializers'
5import { processActivities } from '../../activitypub/process' 5import { processActivities } from '../../activitypub/process'
6import { ActivitypubHttpBroadcastPayload } from './activitypub-http-broadcast' 6import { ActivitypubHttpBroadcastPayload } from './activitypub-http-broadcast'
7 7
@@ -18,7 +18,8 @@ async function processActivityPubHttpFetcher (job: kue.Job) {
18 method: 'GET', 18 method: 'GET',
19 uri: '', 19 uri: '',
20 json: true, 20 json: true,
21 activityPub: true 21 activityPub: true,
22 timeout: JOB_REQUEST_TIMEOUT
22 } 23 }
23 24
24 for (const uri of payload.uris) { 25 for (const uri of payload.uris) {
diff --git a/server/lib/job-queue/handlers/activitypub-http-unicast.ts b/server/lib/job-queue/handlers/activitypub-http-unicast.ts
index e1e1824e5..173f3bb52 100644
--- a/server/lib/job-queue/handlers/activitypub-http-unicast.ts
+++ b/server/lib/job-queue/handlers/activitypub-http-unicast.ts
@@ -3,6 +3,7 @@ import { logger } from '../../../helpers/logger'
3import { doRequest } from '../../../helpers/requests' 3import { doRequest } from '../../../helpers/requests'
4import { ActorFollowModel } from '../../../models/activitypub/actor-follow' 4import { ActorFollowModel } from '../../../models/activitypub/actor-follow'
5import { buildSignedRequestOptions, computeBody } from './utils/activitypub-http-utils' 5import { buildSignedRequestOptions, computeBody } from './utils/activitypub-http-utils'
6import { JOB_REQUEST_TIMEOUT } from '../../../initializers'
6 7
7export type ActivitypubHttpUnicastPayload = { 8export type ActivitypubHttpUnicastPayload = {
8 uri: string 9 uri: string
@@ -23,7 +24,8 @@ async function processActivityPubHttpUnicast (job: kue.Job) {
23 method: 'POST', 24 method: 'POST',
24 uri, 25 uri,
25 json: body, 26 json: body,
26 httpSignature: httpSignatureOptions 27 httpSignature: httpSignatureOptions,
28 timeout: JOB_REQUEST_TIMEOUT
27 } 29 }
28 30
29 try { 31 try {