-
Notifications
You must be signed in to change notification settings - Fork 568
/
interface.ts
28 lines (23 loc) 路 910 Bytes
/
interface.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import { IMidwayApplication, IMidwayContext, NextFunction as BaseNextFunction } from '@midwayjs/core';
import { JobId, Job } from 'bull';
export interface IProcessor {
execute(data: any);
}
export interface IQueue<Job> {
runJob(data: Record<string, any>, options?: unknown): Promise<Job>;
getJob(name: string): Promise<Job>;
getQueueName(): string;
}
export interface IQueueManager<Queue extends IQueue<Job>, Job> {
runJob(queueName: string, jobData: any, options?: unknown): Promise<Job|undefined>;
getJob(queueName: string, jobName: string): Promise<Job>;
createQueue(queueName: string, queueOptions?: unknown): Queue;
getQueue(queueName: string): Queue;
}
export interface Application extends IMidwayApplication<Context> {}
export type NextFunction = BaseNextFunction;
export interface Context extends IMidwayContext {
jobId: JobId;
job: Job;
from: new (...args) => IProcessor;
}