2017-05-22 14:58:25 -04:00
|
|
|
import * as Sequelize from 'sequelize'
|
2017-07-05 07:26:25 -04:00
|
|
|
import * as Promise from 'bluebird'
|
2017-05-22 14:58:25 -04:00
|
|
|
|
2017-07-05 07:26:25 -04:00
|
|
|
import { AbstractRequestClass } from './abstract-request-interface'
|
2017-09-07 09:27:35 -04:00
|
|
|
import { PodInstance, PodAttributes } from '../pod/pod-interface'
|
2017-06-16 04:36:18 -04:00
|
|
|
import { RequestEndpoint } from '../../../shared/models/request-scheduler.model'
|
2017-06-10 16:15:25 -04:00
|
|
|
|
|
|
|
export type RequestsGrouped = {
|
|
|
|
[ podId: number ]: {
|
|
|
|
request: RequestInstance,
|
|
|
|
pod: PodInstance
|
|
|
|
}[]
|
|
|
|
}
|
2017-05-22 14:58:25 -04:00
|
|
|
|
|
|
|
export namespace RequestMethods {
|
2017-07-05 07:26:25 -04:00
|
|
|
export type CountTotalRequests = () => Promise<number>
|
2017-06-10 16:15:25 -04:00
|
|
|
|
2017-07-05 07:26:25 -04:00
|
|
|
export type ListWithLimitAndRandom = (limitPods: number, limitRequestsPerPod: number) => Promise<RequestsGrouped>
|
2017-06-10 16:15:25 -04:00
|
|
|
|
2017-07-05 07:26:25 -04:00
|
|
|
export type RemoveWithEmptyTo = () => Promise<number>
|
2017-06-10 16:15:25 -04:00
|
|
|
|
2017-07-05 07:26:25 -04:00
|
|
|
export type RemoveAll = () => Promise<void>
|
2017-05-22 14:58:25 -04:00
|
|
|
}
|
|
|
|
|
2017-07-05 07:26:25 -04:00
|
|
|
export interface RequestClass extends AbstractRequestClass<RequestsGrouped> {
|
2017-05-22 14:58:25 -04:00
|
|
|
countTotalRequests: RequestMethods.CountTotalRequests
|
|
|
|
listWithLimitAndRandom: RequestMethods.ListWithLimitAndRandom
|
|
|
|
removeWithEmptyTo: RequestMethods.RemoveWithEmptyTo
|
|
|
|
removeAll: RequestMethods.RemoveAll
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface RequestAttributes {
|
|
|
|
request: object
|
2017-06-16 04:36:18 -04:00
|
|
|
endpoint: RequestEndpoint
|
2017-05-22 14:58:25 -04:00
|
|
|
}
|
|
|
|
|
2017-06-10 16:15:25 -04:00
|
|
|
export interface RequestInstance extends RequestClass, RequestAttributes, Sequelize.Instance<RequestAttributes> {
|
2017-05-22 14:58:25 -04:00
|
|
|
id: number
|
|
|
|
createdAt: Date
|
|
|
|
updatedAt: Date
|
|
|
|
|
|
|
|
setPods: Sequelize.HasManySetAssociationsMixin<PodAttributes, number>
|
2017-06-10 16:15:25 -04:00
|
|
|
Pods: PodInstance[]
|
2017-05-22 14:58:25 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface RequestModel extends RequestClass, Sequelize.Model<RequestInstance, RequestAttributes> {}
|