-
Notifications
You must be signed in to change notification settings - Fork 118
/
IProcessor.ts
45 lines (39 loc) · 1.24 KB
/
IProcessor.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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import {IHttp, IModify, IPersistence, IRead} from '../accessors';
/** Represents a processor that is used by the scheduler methods */
export interface IProcessor {
/** The processor's identifier */
id: string;
/** If provided, the processor will be configured with the setting as soon as it gets registered */
startupSetting?: StartupSetting;
/** The function that will be run on a given scheudle */
processor(jobContext: IJobContext, read: IRead, modify: IModify, http: IHttp, persis: IPersistence): Promise<void>;
}
/** The `data` object provided to the processor during the registering process */
export interface IJobContext {
[key: string]: any;
}
type StartupSetting = IOnetimeStartup | IRecurringStartup;
/**
* Processor setting for running once after being registered
*/
export interface IOnetimeStartup {
type: StartupType.ONETIME;
when: string | Date;
data?: object;
}
/**
* Processor setting for running recurringly after being registered
*/
export interface IRecurringStartup {
type: StartupType.RECURRING;
interval: string | number;
skipImmediate?: boolean;
data?: object;
}
/**
* Jobs' startup types
*/
export enum StartupType {
ONETIME = 'onetime',
RECURRING = 'recurring',
}