aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api/request-schedulers.ts
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-11-10 17:27:49 +0100
committerChocobozzz <florian.bigard@gmail.com>2017-11-27 19:40:51 +0100
commit571389d43b8fc8aaf27e77c06f19b320b08dbbc9 (patch)
treee57173bcd0590d939c28952a29258fd02a281e35 /server/controllers/api/request-schedulers.ts
parent38fa2065831b5f55be0d7f30f19a62c967397208 (diff)
downloadPeerTube-571389d43b8fc8aaf27e77c06f19b320b08dbbc9.tar.gz
PeerTube-571389d43b8fc8aaf27e77c06f19b320b08dbbc9.tar.zst
PeerTube-571389d43b8fc8aaf27e77c06f19b320b08dbbc9.zip
Make it compile at least
Diffstat (limited to 'server/controllers/api/request-schedulers.ts')
-rw-r--r--server/controllers/api/request-schedulers.ts53
1 files changed, 0 insertions, 53 deletions
diff --git a/server/controllers/api/request-schedulers.ts b/server/controllers/api/request-schedulers.ts
deleted file mode 100644
index 4c8fbe18b..000000000
--- a/server/controllers/api/request-schedulers.ts
+++ /dev/null
@@ -1,53 +0,0 @@
1import * as express from 'express'
2import * as Bluebird from 'bluebird'
3
4import {
5 AbstractRequestScheduler,
6 getRequestScheduler,
7 getRequestVideoQaduScheduler,
8 getRequestVideoEventScheduler
9} from '../../lib'
10import { authenticate, ensureUserHasRight, asyncMiddleware } from '../../middlewares'
11import { RequestSchedulerStatsAttributes, UserRight } from '../../../shared'
12
13const requestSchedulerRouter = express.Router()
14
15requestSchedulerRouter.get('/stats',
16 authenticate,
17 ensureUserHasRight(UserRight.MANAGE_REQUEST_SCHEDULERS),
18 asyncMiddleware(getRequestSchedulersStats)
19)
20
21// ---------------------------------------------------------------------------
22
23export {
24 requestSchedulerRouter
25}
26
27// ---------------------------------------------------------------------------
28
29async function getRequestSchedulersStats (req: express.Request, res: express.Response, next: express.NextFunction) {
30 const result = await Bluebird.props({
31 requestScheduler: buildRequestSchedulerStats(getRequestScheduler()),
32 requestVideoQaduScheduler: buildRequestSchedulerStats(getRequestVideoQaduScheduler()),
33 requestVideoEventScheduler: buildRequestSchedulerStats(getRequestVideoEventScheduler())
34 })
35
36 return res.json(result)
37}
38
39// ---------------------------------------------------------------------------
40
41async function buildRequestSchedulerStats (requestScheduler: AbstractRequestScheduler<any>) {
42 const count = await requestScheduler.remainingRequestsCount()
43
44 const result: RequestSchedulerStatsAttributes = {
45 totalRequests: count,
46 requestsLimitPods: requestScheduler.limitPods,
47 requestsLimitPerPod: requestScheduler.limitPerPod,
48 remainingMilliSeconds: requestScheduler.remainingMilliSeconds(),
49 milliSecondsInterval: requestScheduler.requestInterval
50 }
51
52 return result
53}