diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-06-25 17:19:46 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-06-25 17:19:46 +0200 |
commit | e636eb88101a51399057c86477af6677f5614d48 (patch) | |
tree | ba56f0da932613c8013a2c52905ded1987cd6d6d /server/controllers/api/requests.ts | |
parent | 4f133041819409a72cf70fa2fa6c4df14c6de4fd (diff) | |
download | PeerTube-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.ts | 59 |
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 @@ | |||
1 | import * as express from 'express' | ||
2 | import { parallel } from 'async' | ||
3 | |||
4 | import { | ||
5 | AbstractRequestScheduler, | ||
6 | getRequestScheduler, | ||
7 | getRequestVideoQaduScheduler, | ||
8 | getRequestVideoEventScheduler | ||
9 | } from '../../lib' | ||
10 | import { authenticate, ensureIsAdmin } from '../../middlewares' | ||
11 | import { RequestSchedulerAttributes } from '../../../shared' | ||
12 | |||
13 | const requestsRouter = express.Router() | ||
14 | |||
15 | requestsRouter.get('/stats', | ||
16 | authenticate, | ||
17 | ensureIsAdmin, | ||
18 | getStatsRequests | ||
19 | ) | ||
20 | |||
21 | // --------------------------------------------------------------------------- | ||
22 | |||
23 | export { | ||
24 | requestsRouter | ||
25 | } | ||
26 | |||
27 | // --------------------------------------------------------------------------- | ||
28 | |||
29 | function 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 | |||
43 | function 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 | } | ||