]>
Commit | Line | Data |
---|---|---|
e02643f3 C |
1 | import * as Sequelize from 'sequelize' |
2 | ||
74889a71 | 3 | import { PodInstance, PodAttributes } from '../pod' |
ee9e7b61 | 4 | import { RequestEndpoint } from '../../../shared/models/request-scheduler.model' |
69818c93 C |
5 | |
6 | export type RequestsGrouped = { | |
7 | [ podId: number ]: { | |
8 | request: RequestInstance, | |
9 | pod: PodInstance | |
10 | }[] | |
11 | } | |
e02643f3 C |
12 | |
13 | export namespace RequestMethods { | |
69818c93 C |
14 | export type CountTotalRequestsCallback = (err: Error, total: number) => void |
15 | export type CountTotalRequests = (callback: CountTotalRequestsCallback) => void | |
16 | ||
17 | export type ListWithLimitAndRandomCallback = (err: Error, requestsGrouped?: RequestsGrouped) => void | |
18 | export type ListWithLimitAndRandom = (limitPods, limitRequestsPerPod, callback: ListWithLimitAndRandomCallback) => void | |
19 | ||
20 | export type RemoveWithEmptyToCallback = (err: Error) => void | |
21 | export type RemoveWithEmptyTo = (callback: RemoveWithEmptyToCallback) => void | |
22 | ||
23 | export type RemoveAllCallback = (err: Error) => void | |
24 | export type RemoveAll = (callback: RemoveAllCallback) => void | |
e02643f3 C |
25 | } |
26 | ||
27 | export interface RequestClass { | |
28 | countTotalRequests: RequestMethods.CountTotalRequests | |
29 | listWithLimitAndRandom: RequestMethods.ListWithLimitAndRandom | |
30 | removeWithEmptyTo: RequestMethods.RemoveWithEmptyTo | |
31 | removeAll: RequestMethods.RemoveAll | |
32 | } | |
33 | ||
34 | export interface RequestAttributes { | |
35 | request: object | |
ee9e7b61 | 36 | endpoint: RequestEndpoint |
e02643f3 C |
37 | } |
38 | ||
69818c93 | 39 | export interface RequestInstance extends RequestClass, RequestAttributes, Sequelize.Instance<RequestAttributes> { |
e02643f3 C |
40 | id: number |
41 | createdAt: Date | |
42 | updatedAt: Date | |
43 | ||
44 | setPods: Sequelize.HasManySetAssociationsMixin<PodAttributes, number> | |
69818c93 | 45 | Pods: PodInstance[] |
e02643f3 C |
46 | } |
47 | ||
48 | export interface RequestModel extends RequestClass, Sequelize.Model<RequestInstance, RequestAttributes> {} |