aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api/request-schedulers.ts
diff options
context:
space:
mode:
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}