X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Flib%2Fbase-request-scheduler.js;h=4709c7960fee4c97b05c0e377b1ee11e81b3be06;hb=72329aaa28bcbb678443900233cc47cff7ba1509;hp=309c1a26166c06ec22c4b4161fb45ca4f7e1eedf;hpb=f282639b07deee1e35403bd86c46ea521fb4845e;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/lib/base-request-scheduler.js b/server/lib/base-request-scheduler.js index 309c1a261..4709c7960 100644 --- a/server/lib/base-request-scheduler.js +++ b/server/lib/base-request-scheduler.js @@ -8,10 +8,10 @@ const logger = require('../helpers/logger') const requests = require('../helpers/requests') module.exports = class BaseRequestScheduler { - constructor (options) { this.lastRequestTimestamp = 0 this.timer = null + this.requestInterval = constants.REQUESTS_INTERVAL } activate () { @@ -21,7 +21,7 @@ module.exports = class BaseRequestScheduler { this.timer = setInterval(() => { this.lastRequestTimestamp = Date.now() this.makeRequests() - }, constants.REQUESTS_INTERVAL) + }, this.requestInterval) } deactivate () { @@ -41,6 +41,10 @@ module.exports = class BaseRequestScheduler { return constants.REQUESTS_INTERVAL - (Date.now() - this.lastRequestTimestamp) } + remainingRequestsCount (callback) { + return this.getRequestModel().countTotalRequests(callback) + } + // --------------------------------------------------------------------------- // Make a requests to friends of a certain type