diff options
Diffstat (limited to 'server/lib')
-rw-r--r-- | server/lib/base-request-scheduler.js | 7 | ||||
-rw-r--r-- | server/lib/friends.js | 31 |
2 files changed, 29 insertions, 9 deletions
diff --git a/server/lib/base-request-scheduler.js b/server/lib/base-request-scheduler.js index 309c1a261..1c6b78297 100644 --- a/server/lib/base-request-scheduler.js +++ b/server/lib/base-request-scheduler.js | |||
@@ -12,6 +12,7 @@ module.exports = class BaseRequestScheduler { | |||
12 | constructor (options) { | 12 | constructor (options) { |
13 | this.lastRequestTimestamp = 0 | 13 | this.lastRequestTimestamp = 0 |
14 | this.timer = null | 14 | this.timer = null |
15 | this.requestInterval = constants.REQUESTS_INTERVAL | ||
15 | } | 16 | } |
16 | 17 | ||
17 | activate () { | 18 | activate () { |
@@ -21,7 +22,7 @@ module.exports = class BaseRequestScheduler { | |||
21 | this.timer = setInterval(() => { | 22 | this.timer = setInterval(() => { |
22 | this.lastRequestTimestamp = Date.now() | 23 | this.lastRequestTimestamp = Date.now() |
23 | this.makeRequests() | 24 | this.makeRequests() |
24 | }, constants.REQUESTS_INTERVAL) | 25 | }, this.requestInterval) |
25 | } | 26 | } |
26 | 27 | ||
27 | deactivate () { | 28 | deactivate () { |
@@ -41,6 +42,10 @@ module.exports = class BaseRequestScheduler { | |||
41 | return constants.REQUESTS_INTERVAL - (Date.now() - this.lastRequestTimestamp) | 42 | return constants.REQUESTS_INTERVAL - (Date.now() - this.lastRequestTimestamp) |
42 | } | 43 | } |
43 | 44 | ||
45 | remainingRequestsCount (callback) { | ||
46 | return this.getRequestModel().countTotalRequests(callback) | ||
47 | } | ||
48 | |||
44 | // --------------------------------------------------------------------------- | 49 | // --------------------------------------------------------------------------- |
45 | 50 | ||
46 | // Make a requests to friends of a certain type | 51 | // Make a requests to friends of a certain type |
diff --git a/server/lib/friends.js b/server/lib/friends.js index 203f0e52c..7bd087d8c 100644 --- a/server/lib/friends.js +++ b/server/lib/friends.js | |||
@@ -19,8 +19,8 @@ const RequestVideoEventScheduler = require('./request-video-event-scheduler') | |||
19 | const ENDPOINT_ACTIONS = constants.REQUEST_ENDPOINT_ACTIONS[constants.REQUEST_ENDPOINTS.VIDEOS] | 19 | const ENDPOINT_ACTIONS = constants.REQUEST_ENDPOINT_ACTIONS[constants.REQUEST_ENDPOINTS.VIDEOS] |
20 | 20 | ||
21 | const requestScheduler = new RequestScheduler() | 21 | const requestScheduler = new RequestScheduler() |
22 | const requestSchedulerVideoQadu = new RequestVideoQaduScheduler() | 22 | const requestVideoQaduScheduler = new RequestVideoQaduScheduler() |
23 | const requestSchedulerVideoEvent = new RequestVideoEventScheduler() | 23 | const requestVideoEventScheduler = new RequestVideoEventScheduler() |
24 | 24 | ||
25 | const friends = { | 25 | const friends = { |
26 | activate, | 26 | activate, |
@@ -33,13 +33,16 @@ const friends = { | |||
33 | makeFriends, | 33 | makeFriends, |
34 | quitFriends, | 34 | quitFriends, |
35 | removeVideoToFriends, | 35 | removeVideoToFriends, |
36 | sendOwnedVideosToPod | 36 | sendOwnedVideosToPod, |
37 | getRequestScheduler, | ||
38 | getRequestVideoQaduScheduler, | ||
39 | getRequestVideoEventScheduler | ||
37 | } | 40 | } |
38 | 41 | ||
39 | function activate () { | 42 | function activate () { |
40 | requestScheduler.activate() | 43 | requestScheduler.activate() |
41 | requestSchedulerVideoQadu.activate() | 44 | requestVideoQaduScheduler.activate() |
42 | requestSchedulerVideoEvent.activate() | 45 | requestVideoEventScheduler.activate() |
43 | } | 46 | } |
44 | 47 | ||
45 | function addVideoToFriends (videoData, transaction, callback) { | 48 | function addVideoToFriends (videoData, transaction, callback) { |
@@ -142,7 +145,7 @@ function quitFriends (callback) { | |||
142 | }, | 145 | }, |
143 | 146 | ||
144 | function flushVideoQaduRequests (callbackAsync) { | 147 | function flushVideoQaduRequests (callbackAsync) { |
145 | requestSchedulerVideoQadu.flush(err => callbackAsync(err)) | 148 | requestVideoQaduScheduler.flush(err => callbackAsync(err)) |
146 | }, | 149 | }, |
147 | 150 | ||
148 | function getPodsList (callbackAsync) { | 151 | function getPodsList (callbackAsync) { |
@@ -215,6 +218,18 @@ function sendOwnedVideosToPod (podId) { | |||
215 | }) | 218 | }) |
216 | } | 219 | } |
217 | 220 | ||
221 | function getRequestScheduler () { | ||
222 | return requestScheduler | ||
223 | } | ||
224 | |||
225 | function getRequestVideoQaduScheduler () { | ||
226 | return requestVideoQaduScheduler | ||
227 | } | ||
228 | |||
229 | function getRequestVideoEventScheduler () { | ||
230 | return requestVideoEventScheduler | ||
231 | } | ||
232 | |||
218 | // --------------------------------------------------------------------------- | 233 | // --------------------------------------------------------------------------- |
219 | 234 | ||
220 | module.exports = friends | 235 | module.exports = friends |
@@ -345,13 +360,13 @@ function createRequest (options, callback) { | |||
345 | function createVideoQaduRequest (options, callback) { | 360 | function createVideoQaduRequest (options, callback) { |
346 | if (!callback) callback = utils.createEmptyCallback() | 361 | if (!callback) callback = utils.createEmptyCallback() |
347 | 362 | ||
348 | requestSchedulerVideoQadu.createRequest(options, callback) | 363 | requestVideoQaduScheduler.createRequest(options, callback) |
349 | } | 364 | } |
350 | 365 | ||
351 | function createVideoEventRequest (options, callback) { | 366 | function createVideoEventRequest (options, callback) { |
352 | if (!callback) callback = utils.createEmptyCallback() | 367 | if (!callback) callback = utils.createEmptyCallback() |
353 | 368 | ||
354 | requestSchedulerVideoEvent.createRequest(options, callback) | 369 | requestVideoEventScheduler.createRequest(options, callback) |
355 | } | 370 | } |
356 | 371 | ||
357 | function isMe (host) { | 372 | function isMe (host) { |