aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/pod/pod-interface.ts
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-06-16 09:45:46 +0200
committerChocobozzz <florian.bigard@gmail.com>2017-06-16 09:45:46 +0200
commit74889a71fe687dda74f2a687653122327807af36 (patch)
treee938e8b6401b74fbec80513a877d9967f2c0dbcd /server/models/pod/pod-interface.ts
parent15a302943d84bc0978b84fe33110c4daa451d311 (diff)
downloadPeerTube-74889a71fe687dda74f2a687653122327807af36.tar.gz
PeerTube-74889a71fe687dda74f2a687653122327807af36.tar.zst
PeerTube-74889a71fe687dda74f2a687653122327807af36.zip
Reorganize model files
Diffstat (limited to 'server/models/pod/pod-interface.ts')
-rw-r--r--server/models/pod/pod-interface.ts67
1 files changed, 67 insertions, 0 deletions
diff --git a/server/models/pod/pod-interface.ts b/server/models/pod/pod-interface.ts
new file mode 100644
index 000000000..01ccda64c
--- /dev/null
+++ b/server/models/pod/pod-interface.ts
@@ -0,0 +1,67 @@
1import * as Sequelize from 'sequelize'
2
3// Don't use barrel, import just what we need
4import { Pod as FormatedPod } from '../../../shared/models/pod.model'
5
6export namespace PodMethods {
7 export type ToFormatedJSON = () => FormatedPod
8
9 export type CountAllCallback = (err: Error, total: number) => void
10 export type CountAll = (callback) => void
11
12 export type IncrementScoresCallback = (err: Error) => void
13 export type IncrementScores = (ids: number[], value: number, callback?: IncrementScoresCallback) => void
14
15 export type ListCallback = (err: Error, podInstances?: PodInstance[]) => void
16 export type List = (callback: ListCallback) => void
17
18 export type ListAllIdsCallback = (err: Error, ids?: number[]) => void
19 export type ListAllIds = (transaction: Sequelize.Transaction, callback: ListAllIdsCallback) => void
20
21 export type ListRandomPodIdsWithRequestCallback = (err: Error, podInstanceIds?: number[]) => void
22 export type ListRandomPodIdsWithRequest = (limit: number, tableWithPods: string, tableWithPodsJoins: string, callback: ListRandomPodIdsWithRequestCallback) => void
23
24 export type ListBadPodsCallback = (err: Error, podInstances?: PodInstance[]) => void
25 export type ListBadPods = (callback: ListBadPodsCallback) => void
26
27 export type LoadCallback = (err: Error, podInstance: PodInstance) => void
28 export type Load = (id: number, callback: LoadCallback) => void
29
30 export type LoadByHostCallback = (err: Error, podInstance: PodInstance) => void
31 export type LoadByHost = (host: string, callback: LoadByHostCallback) => void
32
33 export type RemoveAllCallback = (err: Error) => void
34 export type RemoveAll = (callback: RemoveAllCallback) => void
35
36 export type UpdatePodsScore = (goodPods: number[], badPods: number[]) => void
37}
38
39export interface PodClass {
40 countAll: PodMethods.CountAll
41 incrementScores: PodMethods.IncrementScores
42 list: PodMethods.List
43 listAllIds: PodMethods.ListAllIds
44 listRandomPodIdsWithRequest: PodMethods.ListRandomPodIdsWithRequest
45 listBadPods: PodMethods.ListBadPods
46 load: PodMethods.Load
47 loadByHost: PodMethods.LoadByHost
48 removeAll: PodMethods.RemoveAll
49 updatePodsScore: PodMethods.UpdatePodsScore
50}
51
52export interface PodAttributes {
53 host?: string
54 publicKey?: string
55 score?: number | Sequelize.literal // Sequelize literal for 'score +' + value
56 email?: string
57}
58
59export interface PodInstance extends PodClass, PodAttributes, Sequelize.Instance<PodAttributes> {
60 id: number
61 createdAt: Date
62 updatedAt: Date
63
64 toFormatedJSON: PodMethods.ToFormatedJSON,
65}
66
67export interface PodModel extends PodClass, Sequelize.Model<PodInstance, PodAttributes> {}