@outloud/adonis-scheduler 1.0.6 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +113 -18
- package/build/_virtual/_@oxc-project_runtime@0.114.0/helpers/decorate.js +10 -0
- package/build/_virtual/_@oxc-project_runtime@0.114.0/helpers/decorateMetadata.js +7 -0
- package/build/commands/make_task.d.ts +16 -15
- package/build/commands/make_task.js +16 -38
- package/build/commands/scheduler_run.d.ts +12 -16
- package/build/commands/scheduler_run.js +28 -41
- package/build/providers/scheduler.provider.d.ts +18 -21
- package/build/providers/scheduler.provider.js +30 -36
- package/build/services/main.d.ts +4 -8
- package/build/services/main.js +6 -5
- package/build/src/command.task.js +18 -0
- package/build/src/config.d.ts +6 -0
- package/build/src/config.js +7 -0
- package/build/src/configure.d.ts +6 -0
- package/build/src/configure.js +15 -0
- package/build/src/helpers.js +9 -0
- package/build/src/index.d.ts +6 -0
- package/build/src/index.js +6 -0
- package/build/src/scheduler.d.ts +36 -0
- package/build/src/scheduler.js +147 -0
- package/build/src/task.d.ts +19 -0
- package/build/src/task.js +22 -0
- package/build/src/types.d.ts +60 -0
- package/build/stubs/config/scheduler.stub +1 -0
- package/package.json +14 -19
- package/build/chunk-7P6J5U6O.js +0 -25
- package/build/chunk-FOVOD6FP.js +0 -185
- package/build/chunk-SHUYVCID.js +0 -4
- package/build/command.task-GUNK3QFY.js +0 -22
- package/build/index.d.ts +0 -14
- package/build/index.js +0 -29
- package/build/scheduler-DO35E0Fu.d.ts +0 -99
- /package/{LICENSE → LICENSE.md} +0 -0
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import { ContainerResolver } from '@adonisjs/core/container';
|
|
2
|
-
import { ContainerBindings } from '@adonisjs/core/types';
|
|
3
|
-
import { LockService } from '@adonisjs/lock/types';
|
|
4
|
-
import { Logger } from '@adonisjs/core/logger';
|
|
5
|
-
import { Emitter } from '@adonisjs/core/events';
|
|
6
|
-
|
|
7
|
-
interface SchedulerConfig {
|
|
8
|
-
/**
|
|
9
|
-
* Should the scheduler start with HTTP server?
|
|
10
|
-
*/
|
|
11
|
-
httpServer: boolean;
|
|
12
|
-
/**
|
|
13
|
-
* Warn when a task is locked and cannot be run
|
|
14
|
-
*/
|
|
15
|
-
warnWhenLocked: boolean;
|
|
16
|
-
/**
|
|
17
|
-
* The default ttl for the lock.
|
|
18
|
-
*/
|
|
19
|
-
lockDuration: number | string;
|
|
20
|
-
}
|
|
21
|
-
interface TaskOptions {
|
|
22
|
-
/**
|
|
23
|
-
* A unique name for the task.
|
|
24
|
-
*/
|
|
25
|
-
name?: string;
|
|
26
|
-
/**
|
|
27
|
-
* The pattern to when the task should run.
|
|
28
|
-
*
|
|
29
|
-
* See https://croner.56k.guru/usage/pattern/ for more information.
|
|
30
|
-
*/
|
|
31
|
-
schedule: string;
|
|
32
|
-
/**
|
|
33
|
-
* Time zone to use for the task.
|
|
34
|
-
*/
|
|
35
|
-
timeZone?: string;
|
|
36
|
-
/**
|
|
37
|
-
* Lock the task to prevent it from running concurrently.
|
|
38
|
-
*
|
|
39
|
-
* If a string or number is provided, it will be as ttl.
|
|
40
|
-
*
|
|
41
|
-
* @default false
|
|
42
|
-
*/
|
|
43
|
-
lock?: boolean | number | string;
|
|
44
|
-
}
|
|
45
|
-
interface TaskRegisterOptions extends TaskOptions {
|
|
46
|
-
command: string | string[];
|
|
47
|
-
}
|
|
48
|
-
type ErrorHandler = (error: Error, task: Task) => (void | Promise<void>);
|
|
49
|
-
interface SchedulerEvents {
|
|
50
|
-
'scheduler:error': {
|
|
51
|
-
error: Error;
|
|
52
|
-
task: Task;
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
type MaybePromise<T> = T | Promise<T>;
|
|
56
|
-
type Factory<T> = () => MaybePromise<{
|
|
57
|
-
default: T;
|
|
58
|
-
} | T>;
|
|
59
|
-
|
|
60
|
-
declare abstract class Task {
|
|
61
|
-
isCanceled: boolean;
|
|
62
|
-
promise?: Promise<any>;
|
|
63
|
-
static options: TaskOptions;
|
|
64
|
-
constructor(..._: any[]);
|
|
65
|
-
get name(): string;
|
|
66
|
-
abstract run(...args: any[]): Promise<void>;
|
|
67
|
-
$cancel(): Promise<void>;
|
|
68
|
-
}
|
|
69
|
-
interface Task {
|
|
70
|
-
onCancel?(): Promise<void>;
|
|
71
|
-
onError?(error: Error): Promise<void>;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
declare class Scheduler {
|
|
75
|
-
private config;
|
|
76
|
-
private resolver;
|
|
77
|
-
private logger;
|
|
78
|
-
private emitter;
|
|
79
|
-
private locks?;
|
|
80
|
-
private definitions;
|
|
81
|
-
private state;
|
|
82
|
-
private errorHandler?;
|
|
83
|
-
constructor(config: SchedulerConfig, resolver: ContainerResolver<ContainerBindings>, logger: Logger, emitter: Emitter<any>, locks?: LockService | undefined);
|
|
84
|
-
register(options: TaskRegisterOptions | Factory<typeof Task>): this;
|
|
85
|
-
start(wait?: boolean): Promise<void>;
|
|
86
|
-
stop(): Promise<void>;
|
|
87
|
-
onError(callback: ErrorHandler): this;
|
|
88
|
-
private load;
|
|
89
|
-
private make;
|
|
90
|
-
private run;
|
|
91
|
-
private hasState;
|
|
92
|
-
private setState;
|
|
93
|
-
private handleError;
|
|
94
|
-
private cancel;
|
|
95
|
-
private terminate;
|
|
96
|
-
private schedule;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
export { type SchedulerConfig as S, Task as T, Scheduler as a, type TaskOptions as b, type SchedulerEvents as c };
|
/package/{LICENSE → LICENSE.md}
RENAMED
|
File without changes
|