aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/request/request-scheduler.ts
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-06-10 22:15:25 +0200
committerChocobozzz <florian.bigard@gmail.com>2017-06-10 22:15:25 +0200
commit69818c9394366b954b6ba3bd697bd9d2b09f2a16 (patch)
treead199a18ec3c322460d6f9523fc383ee562554e0 /server/lib/request/request-scheduler.ts
parent4d4e5cd4dca78480ec7f40e747f424cd107376a4 (diff)
downloadPeerTube-69818c9394366b954b6ba3bd697bd9d2b09f2a16.tar.gz
PeerTube-69818c9394366b954b6ba3bd697bd9d2b09f2a16.tar.zst
PeerTube-69818c9394366b954b6ba3bd697bd9d2b09f2a16.zip
Type functions
Diffstat (limited to 'server/lib/request/request-scheduler.ts')
-rw-r--r--server/lib/request/request-scheduler.ts23
1 files changed, 13 insertions, 10 deletions
diff --git a/server/lib/request/request-scheduler.ts b/server/lib/request/request-scheduler.ts
index 26ffbfb86..69d840eeb 100644
--- a/server/lib/request/request-scheduler.ts
+++ b/server/lib/request/request-scheduler.ts
@@ -1,3 +1,5 @@
1import * as Sequelize from 'sequelize'
2
1import { database as db } from '../../initializers/database' 3import { database as db } from '../../initializers/database'
2import { BaseRequestScheduler } from './base-request-scheduler' 4import { BaseRequestScheduler } from './base-request-scheduler'
3import { logger } from '../../helpers' 5import { logger } from '../../helpers'
@@ -6,6 +8,14 @@ import {
6 REQUESTS_LIMIT_PER_POD 8 REQUESTS_LIMIT_PER_POD
7} from '../../initializers' 9} from '../../initializers'
8 10
11export type RequestSchedulerOptions = {
12 type: string
13 endpoint: string
14 data: Object
15 toIds: number[]
16 transaction: Sequelize.Transaction
17}
18
9class RequestScheduler extends BaseRequestScheduler { 19class RequestScheduler extends BaseRequestScheduler {
10 constructor () { 20 constructor () {
11 super() 21 super()
@@ -25,7 +35,7 @@ class RequestScheduler extends BaseRequestScheduler {
25 return db.RequestToPod 35 return db.RequestToPod
26 } 36 }
27 37
28 buildRequestObjects (requests) { 38 buildRequestObjects (requests: { [ toPodId: number ]: any }) {
29 const requestsToMakeGrouped = {} 39 const requestsToMakeGrouped = {}
30 40
31 Object.keys(requests).forEach(toPodId => { 41 Object.keys(requests).forEach(toPodId => {
@@ -51,14 +61,7 @@ class RequestScheduler extends BaseRequestScheduler {
51 return requestsToMakeGrouped 61 return requestsToMakeGrouped
52 } 62 }
53 63
54 // { type, endpoint, data, toIds, transaction } 64 createRequest ({ type, endpoint, data, toIds, transaction }: RequestSchedulerOptions, callback: (err: Error) => void) {
55 createRequest (options, callback) {
56 const type = options.type
57 const endpoint = options.endpoint
58 const data = options.data
59 const toIds = options.toIds
60 const transaction = options.transaction
61
62 // TODO: check the setPods works 65 // TODO: check the setPods works
63 const podIds = [] 66 const podIds = []
64 67
@@ -77,7 +80,7 @@ class RequestScheduler extends BaseRequestScheduler {
77 } 80 }
78 } 81 }
79 82
80 const dbRequestOptions = { 83 const dbRequestOptions: Sequelize.CreateOptions = {
81 transaction 84 transaction
82 } 85 }
83 86