aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/request/base-request-scheduler.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib/request/base-request-scheduler.ts')
-rw-r--r--server/lib/request/base-request-scheduler.ts16
1 files changed, 9 insertions, 7 deletions
diff --git a/server/lib/request/base-request-scheduler.ts b/server/lib/request/base-request-scheduler.ts
index b7ef6abf9..26bdc2bff 100644
--- a/server/lib/request/base-request-scheduler.ts
+++ b/server/lib/request/base-request-scheduler.ts
@@ -2,6 +2,7 @@ import * as eachLimit from 'async/eachLimit'
2 2
3import { database as db } from '../../initializers/database' 3import { database as db } from '../../initializers/database'
4import { logger, makeSecureRequest } from '../../helpers' 4import { logger, makeSecureRequest } from '../../helpers'
5import { PodInstance } from '../../models'
5import { 6import {
6 API_VERSION, 7 API_VERSION,
7 REQUESTS_IN_PARALLEL, 8 REQUESTS_IN_PARALLEL,
@@ -9,11 +10,12 @@ import {
9} from '../../initializers' 10} from '../../initializers'
10 11
11abstract class BaseRequestScheduler { 12abstract class BaseRequestScheduler {
13 requestInterval: number
14 limitPods: number
15 limitPerPod: number
16
12 protected lastRequestTimestamp: number 17 protected lastRequestTimestamp: number
13 protected timer: NodeJS.Timer 18 protected timer: NodeJS.Timer
14 protected requestInterval: number
15 protected limitPods: number
16 protected limitPerPod: number
17 protected description: string 19 protected description: string
18 20
19 constructor () { 21 constructor () {
@@ -53,24 +55,24 @@ abstract class BaseRequestScheduler {
53 return REQUESTS_INTERVAL - (Date.now() - this.lastRequestTimestamp) 55 return REQUESTS_INTERVAL - (Date.now() - this.lastRequestTimestamp)
54 } 56 }
55 57
56 remainingRequestsCount (callback) { 58 remainingRequestsCount (callback: (err: Error, total: number) => void) {
57 return this.getRequestModel().countTotalRequests(callback) 59 return this.getRequestModel().countTotalRequests(callback)
58 } 60 }
59 61
60 flush (callback) { 62 flush (callback: (err: Error) => void) {
61 this.getRequestModel().removeAll(callback) 63 this.getRequestModel().removeAll(callback)
62 } 64 }
63 65
64 // --------------------------------------------------------------------------- 66 // ---------------------------------------------------------------------------
65 67
66 // Make a requests to friends of a certain type 68 // Make a requests to friends of a certain type
67 protected makeRequest (toPod, requestEndpoint, requestsToMake, callback) { 69 protected makeRequest (toPod: PodInstance, requestEndpoint: string, requestsToMake: Object, callback) {
68 if (!callback) callback = function () { /* empty */ } 70 if (!callback) callback = function () { /* empty */ }
69 71
70 const params = { 72 const params = {
71 toPod: toPod, 73 toPod: toPod,
72 sign: true, // Prove our identity 74 sign: true, // Prove our identity
73 method: 'POST', 75 method: 'POST' as 'POST',
74 path: '/api/' + API_VERSION + '/remote/' + requestEndpoint, 76 path: '/api/' + API_VERSION + '/remote/' + requestEndpoint,
75 data: requestsToMake // Requests we need to make 77 data: requestsToMake // Requests we need to make
76 } 78 }