import { Logger } from 'winston'; import { Application } from 'express'; import * as axios from 'axios'; interface IResponse { msg: string; code: 500 | 200; } interface IRequest { jobId: number; } interface IRunRequest extends IRequest { isKill: Function; logId: number; glueType: string; glueSource: string; logDateTime: number; executorHandler: string; executorParams: any; executorTimeout: number; glueUpdatetime: number; broadcastIndex: number; broadcastTotal: number; executorBlockStrategy: string; } interface IExecutorOptions { /** * @default '/job' */ route?: string; /** * @default 'express' */ appType?: 'express'; /** * @default 'memory' */ logStorage?: 'memory' | 'local'; /** * @default 'xxl-job' */ logLocalName?: string; /** * Assign a common context object to all job handlers (database, redis...) */ context?: T; baseUrl?: string; ip?: string | 'dynamic'; port?: number; app: Application; executorKey: string; accessToken: string; scheduleCenterUrl: string; jobHandlers: Map>; } interface ICallBackOptions { result: any; error?: Error; logId: number; } interface ILogRead { findFlag: boolean; endFlag: boolean; content?: string; lineNum?: number; fromLineNum?: number; } type LogRead = Promise; type IObject = Record; type CallBack = (options: ICallBackOptions) => Promise; type JobHandler = (logger: Logger, request: IRunRequest, params: any, context?: T) => Promise; interface JobKillUtil { isKill: Function; setJobKill: Function; } interface JobObject { id: number; callback: CallBack; jobKill: JobKillUtil; logId: number; logger: Logger; timeout: NodeJS.Timeout | null; } declare function createJobManager(logStorage: string, logLocalName: string, context?: T): { hasJob: (jobId: number) => boolean; getJob: (jobId: number) => JobObject | undefined; runJob: (mainLogger: Logger, jobHandler: JobHandler, request: IRunRequest, callback: CallBack) => Promise<{ code: number; msg: string; }>; finishJob: (options: { jobId: number; func?: CallBack | undefined; result?: R | undefined; error?: Error | undefined; }) => Promise; }; declare const request: axios.AxiosInstance; declare const initJobIsKill: () => { isKill: () => boolean; setJobKill: () => boolean; }; /** * Get the IP address of the current program. * @returns The IP address of the current program */ declare const getProgramIp: () => string; declare function createXxlJobExecutor(options: IExecutorOptions): { initialization: () => Promise; cancel: () => Promise; applyMiddleware: () => void; }; export { CallBack, ICallBackOptions, IExecutorOptions, ILogRead, IObject, IRequest, IResponse, IRunRequest, JobHandler, JobKillUtil, JobObject, LogRead, createJobManager, createXxlJobExecutor, getProgramIp, initJobIsKill, request };