aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api/requests.ts
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-06-25 17:19:46 +0200
committerChocobozzz <florian.bigard@gmail.com>2017-06-25 17:19:46 +0200
commite636eb88101a51399057c86477af6677f5614d48 (patch)
treeba56f0da932613c8013a2c52905ded1987cd6d6d /server/controllers/api/requests.ts
parent4f133041819409a72cf70fa2fa6c4df14c6de4fd (diff)
downloadPeerTube-e636eb88101a51399057c86477af6677f5614d48.tar.gz
PeerTube-e636eb88101a51399057c86477af6677f5614d48.tar.zst
PeerTube-e636eb88101a51399057c86477af6677f5614d48.zip
Requests -> RequestSchedulers
Diffstat (limited to 'server/controllers/api/requests.ts')
-rw-r--r--server/controllers/api/requests.ts59
1 files changed, 0 insertions, 59 deletions
diff --git a/server/controllers/api/requests.ts b/server/controllers/api/requests.ts
deleted file mode 100644
index 5718b59b7..000000000
--- a/server/controllers/api/requests.ts
+++ /dev/null
@@ -1,59 +0,0 @@
1import * as express from 'express'
2import { parallel } from 'async'
3
4import {
5 AbstractRequestScheduler,
6 getRequestScheduler,
7 getRequestVideoQaduScheduler,
8 getRequestVideoEventScheduler
9} from '../../lib'
10import { authenticate, ensureIsAdmin } from '../../middlewares'
11import { RequestSchedulerAttributes } from '../../../shared'
12
13const requestsRouter = express.Router()
14
15requestsRouter.get('/stats',
16 authenticate,
17 ensureIsAdmin,
18 getStatsRequests
19)
20
21// ---------------------------------------------------------------------------
22
23export {
24 requestsRouter
25}
26
27// ---------------------------------------------------------------------------
28
29function getStatsRequests (req: express.Request, res: express.Response, next: express.NextFunction) {
30 parallel({
31 requestScheduler: buildRequestSchedulerFunction(getRequestScheduler()),
32 requestVideoQaduScheduler: buildRequestSchedulerFunction(getRequestVideoQaduScheduler()),
33 requestVideoEventScheduler: buildRequestSchedulerFunction(getRequestVideoEventScheduler())
34 }, function (err, result) {
35 if (err) return next(err)
36
37 return res.json(result)
38 })
39}
40
41// ---------------------------------------------------------------------------
42
43function buildRequestSchedulerFunction (requestScheduler: AbstractRequestScheduler) {
44 return function (callback) {
45 requestScheduler.remainingRequestsCount(function (err, count) {
46 if (err) return callback(err)
47
48 const result: RequestSchedulerAttributes = {
49 totalRequests: count,
50 requestsLimitPods: requestScheduler.limitPods,
51 requestsLimitPerPod: requestScheduler.limitPerPod,
52 remainingMilliSeconds: requestScheduler.remainingMilliSeconds(),
53 milliSecondsInterval: requestScheduler.requestInterval
54 }
55
56 return callback(null, result)
57 })
58 }
59}