@fluojs/cron 1.0.0-beta.2 → 1.0.0-beta.4
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.ko.md +12 -3
- package/README.md +12 -3
- package/dist/decorators.d.ts.map +1 -1
- package/dist/decorators.js +2 -2
- package/dist/expressions.d.ts +3 -0
- package/dist/expressions.d.ts.map +1 -1
- package/dist/expressions.js +3 -0
- package/dist/metadata.d.ts +46 -0
- package/dist/metadata.d.ts.map +1 -1
- package/dist/metadata.js +55 -6
- package/dist/scheduler.d.ts +7 -0
- package/dist/scheduler.d.ts.map +1 -1
- package/dist/scheduler.js +7 -0
- package/dist/task-discovery.d.ts +28 -0
- package/dist/task-discovery.d.ts.map +1 -1
- package/dist/task-discovery.js +31 -0
- package/dist/task-runner.d.ts +3 -0
- package/dist/task-runner.d.ts.map +1 -1
- package/dist/task-runner.js +3 -0
- package/package.json +4 -4
package/README.ko.md
CHANGED
|
@@ -137,9 +137,11 @@ class TaskManager {
|
|
|
137
137
|
}
|
|
138
138
|
```
|
|
139
139
|
|
|
140
|
+
Registry는 `addCron`, `addInterval`, `addTimeout`, `remove`, `enable`, `disable`, `get`, `getAll`, `updateCronExpression`을 제공합니다. Timeout task는 한 번 실행된 뒤 비활성화되지만 registry에는 남아 있어 의도적으로 다시 활성화할 수 있습니다.
|
|
141
|
+
|
|
140
142
|
### 제한된 종료
|
|
141
143
|
|
|
142
|
-
`CronModule`은 애플리케이션 종료 시 실행 중인 작업을
|
|
144
|
+
`CronModule`은 애플리케이션 종료 시 실행 중인 작업을 제한된 타임아웃 안에서 drain합니다. 따라서 하나의 hung task 때문에 프로세스 종료가 영원히 막히지 않습니다.
|
|
143
145
|
|
|
144
146
|
기본적으로 shutdown drain은 최대 `10_000ms` 동안 기다립니다. 이 시간이 지나면 스케줄러는 경고 로그를 남기고 hung task가 끝나기를 더 기다리지 않은 채 종료를 계속합니다. 분산 락을 사용하는 경우 아직 실행 중인 작업이 보유한 락은 timeout 시점에 즉시 해제하지 않습니다. 해당 작업이 정상적으로 끝날 때까지 락 소유권을 유지하거나, 프로세스가 종료된 뒤 Redis TTL로 만료되게 두어 원래 작업이 아직 실행 중인데 다른 노드가 같은 작업을 시작하지 않도록 합니다.
|
|
145
147
|
|
|
@@ -156,6 +158,8 @@ class TaskManager {
|
|
|
156
158
|
class AppModule {}
|
|
157
159
|
```
|
|
158
160
|
|
|
161
|
+
singleton provider/controller만 스케줄링됩니다. Request-scoped 및 transient scheduled class는 경고와 함께 건너뜁니다.
|
|
162
|
+
|
|
159
163
|
## 공개 API 개요
|
|
160
164
|
|
|
161
165
|
### 모듈
|
|
@@ -167,8 +171,11 @@ class AppModule {}
|
|
|
167
171
|
- `@Timeout(ms, options?)`: 일정 시간 지연 후 메서드를 한 번 실행합니다.
|
|
168
172
|
|
|
169
173
|
### 상수 및 토큰
|
|
170
|
-
- `CronExpression`:
|
|
174
|
+
- `CronExpression`: `EVERY_SECOND`, `EVERY_5_SECONDS`, `EVERY_30_SECONDS` 같은 sub-minute preset을 포함한 공통 Cron 패턴 객체입니다.
|
|
171
175
|
- `SCHEDULING_REGISTRY`: `SchedulingRegistry` 서비스를 위한 주입 토큰입니다.
|
|
176
|
+
- `normalizeCronModuleOptions(...)`: module option과 기본값을 정규화합니다.
|
|
177
|
+
- `createCronPlatformStatusSnapshot(...)`: health/readiness 통합을 위한 status snapshot을 생성합니다.
|
|
178
|
+
- 메타데이터 헬퍼와 심볼: `defineSchedulingTaskMetadata`, `defineCronTaskMetadata`, `getSchedulingTaskMetadata`, `getCronTaskMetadata`, `getSchedulingTaskMetadataEntries`, `getCronTaskMetadataEntries`, `schedulingMetadataSymbol`, `cronMetadataSymbol`.
|
|
172
179
|
|
|
173
180
|
|
|
174
181
|
## 관련 패키지
|
|
@@ -180,4 +187,6 @@ class AppModule {}
|
|
|
180
187
|
## 예제 소스
|
|
181
188
|
|
|
182
189
|
- `packages/cron/src/module.test.ts`: 데코레이터 및 모듈 라이프사이클에 대한 종합 테스트.
|
|
183
|
-
- `packages/cron/src/
|
|
190
|
+
- `packages/cron/src/service.ts`: 런타임 스케줄링, registry, shutdown 동작.
|
|
191
|
+
- `packages/cron/src/status.test.ts`: status snapshot 동작.
|
|
192
|
+
- `packages/cron/src/distributed-lock-manager.ts`: Redis distributed lock 동작.
|
package/README.md
CHANGED
|
@@ -137,9 +137,11 @@ class TaskManager {
|
|
|
137
137
|
}
|
|
138
138
|
```
|
|
139
139
|
|
|
140
|
+
The registry exposes `addCron`, `addInterval`, `addTimeout`, `remove`, `enable`, `disable`, `get`, `getAll`, and `updateCronExpression`. Timeout tasks run once, then disable themselves while remaining in the registry so they can be re-enabled deliberately.
|
|
141
|
+
|
|
140
142
|
### Bounded Shutdown
|
|
141
143
|
|
|
142
|
-
`CronModule` drains active task executions during application shutdown
|
|
144
|
+
`CronModule` drains active task executions during application shutdown with a bounded timeout so one hung task cannot block process termination forever.
|
|
143
145
|
|
|
144
146
|
By default the shutdown drain waits up to `10_000ms`. If that timeout expires, the scheduler logs a warning and continues shutdown without waiting for the hung task to settle. When distributed locking is enabled, locks held by still-running tasks are not eagerly released on timeout; they remain owned by that task until it settles normally, or until Redis expires the lock after the process exits. This prevents another node from starting the same job while the original task is still running.
|
|
145
147
|
|
|
@@ -156,6 +158,8 @@ By default the shutdown drain waits up to `10_000ms`. If that timeout expires, t
|
|
|
156
158
|
class AppModule {}
|
|
157
159
|
```
|
|
158
160
|
|
|
161
|
+
Only singleton providers/controllers are scheduled. Request-scoped and transient scheduled classes are skipped with a warning.
|
|
162
|
+
|
|
159
163
|
## Public API Overview
|
|
160
164
|
|
|
161
165
|
### Modules
|
|
@@ -167,8 +171,11 @@ class AppModule {}
|
|
|
167
171
|
- `@Timeout(ms, options?)`: Schedules a method to run once after a delay.
|
|
168
172
|
|
|
169
173
|
### Constants & Tokens
|
|
170
|
-
- `CronExpression`: Enum-like object with common cron patterns
|
|
174
|
+
- `CronExpression`: Enum-like object with common cron patterns, including sub-minute presets such as `EVERY_SECOND`, `EVERY_5_SECONDS`, and `EVERY_30_SECONDS`.
|
|
171
175
|
- `SCHEDULING_REGISTRY`: Injection token for the `SchedulingRegistry` service.
|
|
176
|
+
- `normalizeCronModuleOptions(...)`: Normalizes module options and defaults.
|
|
177
|
+
- `createCronPlatformStatusSnapshot(...)`: Creates a status snapshot for health/readiness integrations.
|
|
178
|
+
- Metadata helpers and symbols: `defineSchedulingTaskMetadata`, `defineCronTaskMetadata`, `getSchedulingTaskMetadata`, `getCronTaskMetadata`, `getSchedulingTaskMetadataEntries`, `getCronTaskMetadataEntries`, `schedulingMetadataSymbol`, `cronMetadataSymbol`.
|
|
172
179
|
|
|
173
180
|
|
|
174
181
|
## Related Packages
|
|
@@ -180,4 +187,6 @@ class AppModule {}
|
|
|
180
187
|
## Example Sources
|
|
181
188
|
|
|
182
189
|
- `packages/cron/src/module.test.ts`: Comprehensive tests for decorators and module lifecycle.
|
|
183
|
-
- `packages/cron/src/
|
|
190
|
+
- `packages/cron/src/service.ts`: Runtime scheduling, registry, and shutdown behavior.
|
|
191
|
+
- `packages/cron/src/status.test.ts`: Status snapshot behavior.
|
|
192
|
+
- `packages/cron/src/distributed-lock-manager.ts`: Redis distributed lock behavior.
|
package/dist/decorators.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decorators.d.ts","sourceRoot":"","sources":["../src/decorators.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAEV,eAAe,EAEf,mBAAmB,EAEnB,kBAAkB,EACnB,MAAM,YAAY,CAAC;AAGpB,KAAK,yBAAyB,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,2BAA2B,KAAK,IAAI,CAAC;AACjG,KAAK,mBAAmB,GAAG,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"decorators.d.ts","sourceRoot":"","sources":["../src/decorators.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAEV,eAAe,EAEf,mBAAmB,EAEnB,kBAAkB,EACnB,MAAM,YAAY,CAAC;AAGpB,KAAK,yBAAyB,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,2BAA2B,KAAK,IAAI,CAAC;AACjG,KAAK,mBAAmB,GAAG,yBAAyB,CAAC;AAqCrD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,IAAI,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,GAAE,eAAoB,GAAG,mBAAmB,CAoB3F;AAED;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,GAAE,mBAAwB,GAAG,mBAAmB,CAgB3F;AAED;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,GAAE,kBAAuB,GAAG,mBAAmB,CAgBzF"}
|
package/dist/decorators.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ensureMetadataSymbol } from '@fluojs/core/internal';
|
|
2
2
|
import { Cron as CronValidator } from 'croner';
|
|
3
3
|
import { schedulingMetadataSymbol } from './metadata.js';
|
|
4
|
+
ensureMetadataSymbol();
|
|
4
5
|
function getStandardMetadataBag(metadata) {
|
|
5
|
-
void metadataSymbol;
|
|
6
6
|
return metadata;
|
|
7
7
|
}
|
|
8
8
|
function defineStandardSchedulingMetadata(metadata, propertyKey, taskMetadata) {
|
package/dist/expressions.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expressions.d.ts","sourceRoot":"","sources":["../src/expressions.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc;;;;;;;;;;;CAWjB,CAAC"}
|
|
1
|
+
{"version":3,"file":"expressions.d.ts","sourceRoot":"","sources":["../src/expressions.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,cAAc;;;;;;;;;;;CAWjB,CAAC"}
|
package/dist/expressions.js
CHANGED
package/dist/metadata.d.ts
CHANGED
|
@@ -1,17 +1,63 @@
|
|
|
1
1
|
import { type MetadataPropertyKey } from '@fluojs/core';
|
|
2
2
|
import type { CronTaskMetadata, SchedulingTaskMetadata } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Define scheduling task metadata.
|
|
5
|
+
*
|
|
6
|
+
* @param target The target.
|
|
7
|
+
* @param propertyKey The property key.
|
|
8
|
+
* @param metadata The metadata.
|
|
9
|
+
*/
|
|
3
10
|
export declare function defineSchedulingTaskMetadata(target: object, propertyKey: MetadataPropertyKey, metadata: SchedulingTaskMetadata): void;
|
|
11
|
+
/**
|
|
12
|
+
* Define cron task metadata.
|
|
13
|
+
*
|
|
14
|
+
* @param target The target.
|
|
15
|
+
* @param propertyKey The property key.
|
|
16
|
+
* @param metadata The metadata.
|
|
17
|
+
*/
|
|
4
18
|
export declare function defineCronTaskMetadata(target: object, propertyKey: MetadataPropertyKey, metadata: CronTaskMetadata): void;
|
|
19
|
+
/**
|
|
20
|
+
* Get scheduling task metadata.
|
|
21
|
+
*
|
|
22
|
+
* @param target The target.
|
|
23
|
+
* @param propertyKey The property key.
|
|
24
|
+
* @returns The get scheduling task metadata result.
|
|
25
|
+
*/
|
|
5
26
|
export declare function getSchedulingTaskMetadata(target: object, propertyKey: MetadataPropertyKey): SchedulingTaskMetadata | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* Get cron task metadata.
|
|
29
|
+
*
|
|
30
|
+
* @param target The target.
|
|
31
|
+
* @param propertyKey The property key.
|
|
32
|
+
* @returns The get cron task metadata result.
|
|
33
|
+
*/
|
|
6
34
|
export declare function getCronTaskMetadata(target: object, propertyKey: MetadataPropertyKey): CronTaskMetadata | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* Get scheduling task metadata entries.
|
|
37
|
+
*
|
|
38
|
+
* @param target The target.
|
|
39
|
+
* @returns The get scheduling task metadata entries result.
|
|
40
|
+
*/
|
|
7
41
|
export declare function getSchedulingTaskMetadataEntries(target: object): Array<{
|
|
8
42
|
metadata: SchedulingTaskMetadata;
|
|
9
43
|
propertyKey: MetadataPropertyKey;
|
|
10
44
|
}>;
|
|
45
|
+
/**
|
|
46
|
+
* Get cron task metadata entries.
|
|
47
|
+
*
|
|
48
|
+
* @param target The target.
|
|
49
|
+
* @returns The get cron task metadata entries result.
|
|
50
|
+
*/
|
|
11
51
|
export declare function getCronTaskMetadataEntries(target: object): Array<{
|
|
12
52
|
metadata: CronTaskMetadata;
|
|
13
53
|
propertyKey: MetadataPropertyKey;
|
|
14
54
|
}>;
|
|
55
|
+
/**
|
|
56
|
+
* Provides the scheduling metadata symbol value.
|
|
57
|
+
*/
|
|
15
58
|
export declare const schedulingMetadataSymbol: symbol;
|
|
59
|
+
/**
|
|
60
|
+
* Provides the cron metadata symbol value.
|
|
61
|
+
*/
|
|
16
62
|
export declare const cronMetadataSymbol: symbol;
|
|
17
63
|
//# sourceMappingURL=metadata.d.ts.map
|
package/dist/metadata.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metadata.d.ts","sourceRoot":"","sources":["../src/metadata.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAGxD,OAAO,KAAK,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"metadata.d.ts","sourceRoot":"","sources":["../src/metadata.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAGxD,OAAO,KAAK,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAgD3E;;;;;;GAMG;AACH,wBAAgB,4BAA4B,CAC1C,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,mBAAmB,EAChC,QAAQ,EAAE,sBAAsB,GAC/B,IAAI,CAEN;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,mBAAmB,EAAE,QAAQ,EAAE,gBAAgB,GAAG,IAAI,CAEzH;AAED;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,mBAAmB,GAAG,sBAAsB,GAAG,SAAS,CAS9H;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,mBAAmB,GAAG,gBAAgB,GAAG,SAAS,CAIlH;AAED;;;;;GAKG;AACH,wBAAgB,gCAAgC,CAC9C,MAAM,EAAE,MAAM,GACb,KAAK,CAAC;IAAE,QAAQ,EAAE,sBAAsB,CAAC;IAAC,WAAW,EAAE,mBAAmB,CAAA;CAAE,CAAC,CAW/E;AAED;;;;;GAKG;AACH,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,MAAM,GAAG,KAAK,CAAC;IAAE,QAAQ,EAAE,gBAAgB,CAAC;IAAC,WAAW,EAAE,mBAAmB,CAAA;CAAE,CAAC,CAIlI;AAED;;GAEG;AACH,eAAO,MAAM,wBAAwB,QAAgC,CAAC;AACtE;;GAEG;AACH,eAAO,MAAM,kBAAkB,QAAgC,CAAC"}
|
package/dist/metadata.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ensureSymbolMetadataPolyfill,
|
|
1
|
+
import { ensureSymbolMetadataPolyfill, getStandardConstructorMetadataBag } from '@fluojs/core/internal';
|
|
2
2
|
void ensureSymbolMetadataPolyfill();
|
|
3
3
|
const standardSchedulingMetadataKey = Symbol.for('fluo.cron.standard.task');
|
|
4
4
|
const schedulingMetadataStore = new WeakMap();
|
|
@@ -29,12 +29,8 @@ function cloneTaskMetadata(metadata) {
|
|
|
29
29
|
}
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
|
-
function getStandardMetadataBag(target) {
|
|
33
|
-
return target[metadataSymbol];
|
|
34
|
-
}
|
|
35
32
|
function getStandardSchedulingMap(target) {
|
|
36
|
-
|
|
37
|
-
return constructor ? getStandardMetadataBag(constructor)?.[standardSchedulingMetadataKey] : undefined;
|
|
33
|
+
return getStandardConstructorMetadataBag(target)?.[standardSchedulingMetadataKey];
|
|
38
34
|
}
|
|
39
35
|
function getOrCreateSchedulingMap(target) {
|
|
40
36
|
let map = schedulingMetadataStore.get(target);
|
|
@@ -44,12 +40,36 @@ function getOrCreateSchedulingMap(target) {
|
|
|
44
40
|
}
|
|
45
41
|
return map;
|
|
46
42
|
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Define scheduling task metadata.
|
|
46
|
+
*
|
|
47
|
+
* @param target The target.
|
|
48
|
+
* @param propertyKey The property key.
|
|
49
|
+
* @param metadata The metadata.
|
|
50
|
+
*/
|
|
47
51
|
export function defineSchedulingTaskMetadata(target, propertyKey, metadata) {
|
|
48
52
|
getOrCreateSchedulingMap(target).set(propertyKey, cloneTaskMetadata(metadata));
|
|
49
53
|
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Define cron task metadata.
|
|
57
|
+
*
|
|
58
|
+
* @param target The target.
|
|
59
|
+
* @param propertyKey The property key.
|
|
60
|
+
* @param metadata The metadata.
|
|
61
|
+
*/
|
|
50
62
|
export function defineCronTaskMetadata(target, propertyKey, metadata) {
|
|
51
63
|
defineSchedulingTaskMetadata(target, propertyKey, metadata);
|
|
52
64
|
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Get scheduling task metadata.
|
|
68
|
+
*
|
|
69
|
+
* @param target The target.
|
|
70
|
+
* @param propertyKey The property key.
|
|
71
|
+
* @returns The get scheduling task metadata result.
|
|
72
|
+
*/
|
|
53
73
|
export function getSchedulingTaskMetadata(target, propertyKey) {
|
|
54
74
|
const stored = schedulingMetadataStore.get(target)?.get(propertyKey);
|
|
55
75
|
const standard = getStandardSchedulingMap(target)?.get(propertyKey);
|
|
@@ -58,10 +78,25 @@ export function getSchedulingTaskMetadata(target, propertyKey) {
|
|
|
58
78
|
}
|
|
59
79
|
return cloneTaskMetadata(stored ?? standard);
|
|
60
80
|
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Get cron task metadata.
|
|
84
|
+
*
|
|
85
|
+
* @param target The target.
|
|
86
|
+
* @param propertyKey The property key.
|
|
87
|
+
* @returns The get cron task metadata result.
|
|
88
|
+
*/
|
|
61
89
|
export function getCronTaskMetadata(target, propertyKey) {
|
|
62
90
|
const metadata = getSchedulingTaskMetadata(target, propertyKey);
|
|
63
91
|
return metadata?.kind === 'cron' ? metadata : undefined;
|
|
64
92
|
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Get scheduling task metadata entries.
|
|
96
|
+
*
|
|
97
|
+
* @param target The target.
|
|
98
|
+
* @returns The get scheduling task metadata entries result.
|
|
99
|
+
*/
|
|
65
100
|
export function getSchedulingTaskMetadataEntries(target) {
|
|
66
101
|
const stored = schedulingMetadataStore.get(target) ?? new Map();
|
|
67
102
|
const standard = getStandardSchedulingMap(target) ?? new Map();
|
|
@@ -71,8 +106,22 @@ export function getSchedulingTaskMetadataEntries(target) {
|
|
|
71
106
|
propertyKey
|
|
72
107
|
})).filter(entry => entry.metadata !== undefined);
|
|
73
108
|
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Get cron task metadata entries.
|
|
112
|
+
*
|
|
113
|
+
* @param target The target.
|
|
114
|
+
* @returns The get cron task metadata entries result.
|
|
115
|
+
*/
|
|
74
116
|
export function getCronTaskMetadataEntries(target) {
|
|
75
117
|
return getSchedulingTaskMetadataEntries(target).filter(entry => entry.metadata.kind === 'cron');
|
|
76
118
|
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Provides the scheduling metadata symbol value.
|
|
122
|
+
*/
|
|
77
123
|
export const schedulingMetadataSymbol = standardSchedulingMetadataKey;
|
|
124
|
+
/**
|
|
125
|
+
* Provides the cron metadata symbol value.
|
|
126
|
+
*/
|
|
78
127
|
export const cronMetadataSymbol = standardSchedulingMetadataKey;
|
package/dist/scheduler.d.ts
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
1
|
import type { CronScheduler } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Provides the default cron scheduler value.
|
|
4
|
+
*
|
|
5
|
+
* @param expression The expression.
|
|
6
|
+
* @param options The options.
|
|
7
|
+
* @param callback The callback.
|
|
8
|
+
*/
|
|
2
9
|
export declare const defaultCronScheduler: CronScheduler;
|
|
3
10
|
//# sourceMappingURL=scheduler.d.ts.map
|
package/dist/scheduler.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scheduler.d.ts","sourceRoot":"","sources":["../src/scheduler.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,eAAO,MAAM,oBAAoB,EAAE,aAMlC,CAAC"}
|
|
1
|
+
{"version":3,"file":"scheduler.d.ts","sourceRoot":"","sources":["../src/scheduler.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,EAAE,aAMlC,CAAC"}
|
package/dist/scheduler.js
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import { Cron as Croner } from 'croner';
|
|
2
|
+
/**
|
|
3
|
+
* Provides the default cron scheduler value.
|
|
4
|
+
*
|
|
5
|
+
* @param expression The expression.
|
|
6
|
+
* @param options The options.
|
|
7
|
+
* @param callback The callback.
|
|
8
|
+
*/
|
|
2
9
|
export const defaultCronScheduler = (expression, options, callback) => {
|
|
3
10
|
return new Croner(expression, {
|
|
4
11
|
name: options.name,
|
package/dist/task-discovery.d.ts
CHANGED
|
@@ -1,8 +1,36 @@
|
|
|
1
1
|
import { type MetadataPropertyKey } from '@fluojs/core';
|
|
2
2
|
import type { ApplicationLogger, CompiledModule } from '@fluojs/runtime';
|
|
3
3
|
import type { CronTaskDescriptor, NormalizedCronModuleOptions } from './types.js';
|
|
4
|
+
/**
|
|
5
|
+
* Build default task name.
|
|
6
|
+
*
|
|
7
|
+
* @param targetName The target name.
|
|
8
|
+
* @param methodName The method name.
|
|
9
|
+
* @returns The build default task name result.
|
|
10
|
+
*/
|
|
4
11
|
export declare function buildDefaultTaskName(targetName: string, methodName: string): string;
|
|
12
|
+
/**
|
|
13
|
+
* Create lock key.
|
|
14
|
+
*
|
|
15
|
+
* @param prefix The prefix.
|
|
16
|
+
* @param taskName The task name.
|
|
17
|
+
* @returns The create lock key result.
|
|
18
|
+
*/
|
|
5
19
|
export declare function createLockKey(prefix: string, taskName: string): string;
|
|
20
|
+
/**
|
|
21
|
+
* Method key to name.
|
|
22
|
+
*
|
|
23
|
+
* @param methodKey The method key.
|
|
24
|
+
* @returns The method key to name result.
|
|
25
|
+
*/
|
|
6
26
|
export declare function methodKeyToName(methodKey: MetadataPropertyKey): string;
|
|
27
|
+
/**
|
|
28
|
+
* Discover cron task descriptors.
|
|
29
|
+
*
|
|
30
|
+
* @param compiledModules The compiled modules.
|
|
31
|
+
* @param options The options.
|
|
32
|
+
* @param logger The logger.
|
|
33
|
+
* @returns The discover cron task descriptors result.
|
|
34
|
+
*/
|
|
7
35
|
export declare function discoverCronTaskDescriptors(compiledModules: readonly CompiledModule[], options: NormalizedCronModuleOptions, logger: ApplicationLogger): CronTaskDescriptor[];
|
|
8
36
|
//# sourceMappingURL=task-discovery.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"task-discovery.d.ts","sourceRoot":"","sources":["../src/task-discovery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,mBAAmB,EAAc,MAAM,cAAc,CAAC;AAGpE,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAGzE,OAAO,KAAK,EAAE,kBAAkB,EAAE,2BAA2B,EAAE,MAAM,YAAY,CAAC;AASlF,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAEnF;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAEtE;AAED,wBAAgB,eAAe,CAAC,SAAS,EAAE,mBAAmB,GAAG,MAAM,CAEtE;AAED,wBAAgB,2BAA2B,CACzC,eAAe,EAAE,SAAS,cAAc,EAAE,EAC1C,OAAO,EAAE,2BAA2B,EACpC,MAAM,EAAE,iBAAiB,GACxB,kBAAkB,EAAE,CA4DtB"}
|
|
1
|
+
{"version":3,"file":"task-discovery.d.ts","sourceRoot":"","sources":["../src/task-discovery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,mBAAmB,EAAc,MAAM,cAAc,CAAC;AAGpE,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAGzE,OAAO,KAAK,EAAE,kBAAkB,EAAE,2BAA2B,EAAE,MAAM,YAAY,CAAC;AASlF;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAEnF;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAEtE;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,SAAS,EAAE,mBAAmB,GAAG,MAAM,CAEtE;AAED;;;;;;;GAOG;AACH,wBAAgB,2BAA2B,CACzC,eAAe,EAAE,SAAS,cAAc,EAAE,EAC1C,OAAO,EAAE,2BAA2B,EACpC,MAAM,EAAE,iBAAiB,GACxB,kBAAkB,EAAE,CA4DtB"}
|
package/dist/task-discovery.js
CHANGED
|
@@ -1,14 +1,45 @@
|
|
|
1
1
|
import { getClassDiMetadata } from '@fluojs/core/internal';
|
|
2
2
|
import { getSchedulingTaskMetadataEntries } from './metadata.js';
|
|
3
|
+
/**
|
|
4
|
+
* Build default task name.
|
|
5
|
+
*
|
|
6
|
+
* @param targetName The target name.
|
|
7
|
+
* @param methodName The method name.
|
|
8
|
+
* @returns The build default task name result.
|
|
9
|
+
*/
|
|
3
10
|
export function buildDefaultTaskName(targetName, methodName) {
|
|
4
11
|
return `${targetName}.${methodName}`;
|
|
5
12
|
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Create lock key.
|
|
16
|
+
*
|
|
17
|
+
* @param prefix The prefix.
|
|
18
|
+
* @param taskName The task name.
|
|
19
|
+
* @returns The create lock key result.
|
|
20
|
+
*/
|
|
6
21
|
export function createLockKey(prefix, taskName) {
|
|
7
22
|
return `${prefix}:${taskName}`;
|
|
8
23
|
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Method key to name.
|
|
27
|
+
*
|
|
28
|
+
* @param methodKey The method key.
|
|
29
|
+
* @returns The method key to name result.
|
|
30
|
+
*/
|
|
9
31
|
export function methodKeyToName(methodKey) {
|
|
10
32
|
return typeof methodKey === 'symbol' ? methodKey.toString() : methodKey;
|
|
11
33
|
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Discover cron task descriptors.
|
|
37
|
+
*
|
|
38
|
+
* @param compiledModules The compiled modules.
|
|
39
|
+
* @param options The options.
|
|
40
|
+
* @param logger The logger.
|
|
41
|
+
* @returns The discover cron task descriptors result.
|
|
42
|
+
*/
|
|
12
43
|
export function discoverCronTaskDescriptors(compiledModules, options, logger) {
|
|
13
44
|
const seen = new Map();
|
|
14
45
|
const descriptors = [];
|
package/dist/task-runner.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type { Container } from '@fluojs/di';
|
|
2
2
|
import type { ApplicationLogger } from '@fluojs/runtime';
|
|
3
3
|
import type { CronTaskDescriptor } from './types.js';
|
|
4
|
+
/**
|
|
5
|
+
* Represents the cron task runner.
|
|
6
|
+
*/
|
|
4
7
|
export declare class CronTaskRunner {
|
|
5
8
|
private readonly runtimeContainer;
|
|
6
9
|
private readonly logger;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"task-runner.d.ts","sourceRoot":"","sources":["../src/task-runner.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEzD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAOrD,qBAAa,cAAc;IAEvB,OAAO,CAAC,QAAQ,CAAC,gBAAgB;IACjC,OAAO,CAAC,QAAQ,CAAC,MAAM;gBADN,gBAAgB,EAAE,SAAS,EAC3B,MAAM,EAAE,iBAAiB;IAGtC,WAAW,CACf,UAAU,EAAE,kBAAkB,EAC9B,oBAAoB,CAAC,EAAE,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,GAAG,SAAS,CAAC,GAAG,SAAS,GAC1E,OAAO,CAAC,OAAO,CAAC;YA8BL,qBAAqB;YA8CrB,iBAAiB;YAQjB,kBAAkB;YAQlB,gBAAgB;YAUhB,gBAAgB;CAW/B"}
|
|
1
|
+
{"version":3,"file":"task-runner.d.ts","sourceRoot":"","sources":["../src/task-runner.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEzD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAOrD;;GAEG;AACH,qBAAa,cAAc;IAEvB,OAAO,CAAC,QAAQ,CAAC,gBAAgB;IACjC,OAAO,CAAC,QAAQ,CAAC,MAAM;gBADN,gBAAgB,EAAE,SAAS,EAC3B,MAAM,EAAE,iBAAiB;IAGtC,WAAW,CACf,UAAU,EAAE,kBAAkB,EAC9B,oBAAoB,CAAC,EAAE,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,GAAG,SAAS,CAAC,GAAG,SAAS,GAC1E,OAAO,CAAC,OAAO,CAAC;YA8BL,qBAAqB;YA8CrB,iBAAiB;YAQjB,kBAAkB;YAQlB,gBAAgB;YAUhB,gBAAgB;CAW/B"}
|
package/dist/task-runner.js
CHANGED
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"timeout",
|
|
10
10
|
"distributed-lock"
|
|
11
11
|
],
|
|
12
|
-
"version": "1.0.0-beta.
|
|
12
|
+
"version": "1.0.0-beta.4",
|
|
13
13
|
"private": false,
|
|
14
14
|
"license": "MIT",
|
|
15
15
|
"repository": {
|
|
@@ -37,10 +37,10 @@
|
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"croner": "^8.1.2",
|
|
40
|
-
"@fluojs/core": "^1.0.0-beta.
|
|
41
|
-
"@fluojs/di": "^1.0.0-beta.
|
|
40
|
+
"@fluojs/core": "^1.0.0-beta.4",
|
|
41
|
+
"@fluojs/di": "^1.0.0-beta.6",
|
|
42
42
|
"@fluojs/redis": "^1.0.0-beta.2",
|
|
43
|
-
"@fluojs/runtime": "^1.0.0-beta.
|
|
43
|
+
"@fluojs/runtime": "^1.0.0-beta.11"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"vitest": "^3.2.4"
|