diff options
author | Chocobozzz <me@florianbigard.com> | 2018-05-09 09:08:22 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-05-09 09:08:22 +0200 |
commit | 71e3dfda4e2bcc228415c0d66b09a84bb73dddd1 (patch) | |
tree | f7b17a3f01b5e796b73debcd3f11fa0bb56f18bb /server/lib/job-queue/handlers | |
parent | 7797350a0e539b872bdcb59aa07fa9b16cb2db7a (diff) | |
download | PeerTube-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')
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' | |||
4 | import { doRequest } from '../../../helpers/requests' | 4 | import { doRequest } from '../../../helpers/requests' |
5 | import { ActorFollowModel } from '../../../models/activitypub/actor-follow' | 5 | import { ActorFollowModel } from '../../../models/activitypub/actor-follow' |
6 | import { buildSignedRequestOptions, computeBody } from './utils/activitypub-http-utils' | 6 | import { buildSignedRequestOptions, computeBody } from './utils/activitypub-http-utils' |
7 | import { BROADCAST_CONCURRENCY } from '../../../initializers' | 7 | import { BROADCAST_CONCURRENCY, JOB_REQUEST_TIMEOUT } from '../../../initializers' |
8 | 8 | ||
9 | export type ActivitypubHttpBroadcastPayload = { | 9 | export 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 @@ | |||
1 | import * as kue from 'kue' | 1 | import * as kue from 'kue' |
2 | import { logger } from '../../../helpers/logger' | 2 | import { logger } from '../../../helpers/logger' |
3 | import { doRequest } from '../../../helpers/requests' | 3 | import { doRequest } from '../../../helpers/requests' |
4 | import { ACTIVITY_PUB } from '../../../initializers' | 4 | import { ACTIVITY_PUB, JOB_REQUEST_TIMEOUT } from '../../../initializers' |
5 | import { processActivities } from '../../activitypub/process' | 5 | import { processActivities } from '../../activitypub/process' |
6 | import { ActivitypubHttpBroadcastPayload } from './activitypub-http-broadcast' | 6 | import { 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' | |||
3 | import { doRequest } from '../../../helpers/requests' | 3 | import { doRequest } from '../../../helpers/requests' |
4 | import { ActorFollowModel } from '../../../models/activitypub/actor-follow' | 4 | import { ActorFollowModel } from '../../../models/activitypub/actor-follow' |
5 | import { buildSignedRequestOptions, computeBody } from './utils/activitypub-http-utils' | 5 | import { buildSignedRequestOptions, computeBody } from './utils/activitypub-http-utils' |
6 | import { JOB_REQUEST_TIMEOUT } from '../../../initializers' | ||
6 | 7 | ||
7 | export type ActivitypubHttpUnicastPayload = { | 8 | export 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 { |