@eggjs/schedule-plugin 4.0.0-beta.34 → 4.0.0-beta.36
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/dist/agent.d.ts +10 -6
- package/dist/agent.js +25 -28
- package/dist/app.d.ts +13 -9
- package/dist/app.js +27 -23
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -1
- package/dist/lib/EggScheduleAdapter.d.ts +9 -5
- package/dist/lib/EggScheduleAdapter.js +15 -14
- package/dist/lib/EggScheduleMetadataConvertor.d.ts +12 -9
- package/dist/lib/EggScheduleMetadataConvertor.js +20 -16
- package/dist/lib/SchedulePrototypeHook.d.ts +8 -4
- package/dist/lib/SchedulePrototypeHook.js +13 -14
- package/dist/lib/ScheduleSubscriberRegister.d.ts +11 -7
- package/dist/lib/ScheduleSubscriberRegister.js +25 -26
- package/dist/lib/ScheduleWorkerLoadUnitHook.d.ts +11 -7
- package/dist/lib/ScheduleWorkerLoadUnitHook.js +21 -21
- package/dist/lib/ScheduleWorkerRegister.d.ts +11 -7
- package/dist/lib/ScheduleWorkerRegister.js +28 -24
- package/dist/types.d.ts +1 -1
- package/dist/types.js +3 -2
- package/package.json +46 -50
package/dist/agent.d.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { Agent, ILifecycleBoot } from "egg";
|
|
2
|
+
|
|
3
|
+
//#region src/agent.d.ts
|
|
4
|
+
declare class ScheduleAppBootHook implements ILifecycleBoot {
|
|
5
|
+
private readonly agent;
|
|
6
|
+
private readonly scheduleSubscriberRegister;
|
|
7
|
+
constructor(agent: Agent);
|
|
8
|
+
didLoad(): Promise<void>;
|
|
7
9
|
}
|
|
10
|
+
//#endregion
|
|
11
|
+
export { ScheduleAppBootHook as default };
|
package/dist/agent.js
CHANGED
|
@@ -1,29 +1,26 @@
|
|
|
1
|
-
import { LoaderFactory } from '@eggjs/tegg-loader';
|
|
2
|
-
import { EggLoadUnitType } from '@eggjs/metadata';
|
|
3
|
-
import { ScheduleInfoUtil, ScheduleMetaBuilder } from '@eggjs/schedule-decorator';
|
|
4
1
|
import { ScheduleSubscriberRegister } from "./lib/ScheduleSubscriberRegister.js";
|
|
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
|
-
|
|
2
|
+
import { EggLoadUnitType } from "@eggjs/metadata";
|
|
3
|
+
import { ScheduleInfoUtil, ScheduleMetaBuilder } from "@eggjs/schedule-decorator";
|
|
4
|
+
import { LoaderFactory } from "@eggjs/tegg-loader";
|
|
5
|
+
|
|
6
|
+
//#region src/agent.ts
|
|
7
|
+
var ScheduleAppBootHook = class {
|
|
8
|
+
agent;
|
|
9
|
+
scheduleSubscriberRegister;
|
|
10
|
+
constructor(agent) {
|
|
11
|
+
this.agent = agent;
|
|
12
|
+
this.scheduleSubscriberRegister = new ScheduleSubscriberRegister(this.agent);
|
|
13
|
+
}
|
|
14
|
+
async didLoad() {
|
|
15
|
+
for (const moduleConfig of this.agent.moduleReferences) {
|
|
16
|
+
const clazzList = await LoaderFactory.createLoader(moduleConfig.path, EggLoadUnitType.MODULE).load();
|
|
17
|
+
for (const clazz of clazzList) if (ScheduleInfoUtil.isSchedule(clazz)) {
|
|
18
|
+
const metadata = new ScheduleMetaBuilder(clazz).build();
|
|
19
|
+
this.scheduleSubscriberRegister.register(clazz, metadata);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
//#endregion
|
|
26
|
+
export { ScheduleAppBootHook as default };
|
package/dist/app.d.ts
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { Application, ILifecycleBoot } from "egg";
|
|
2
|
+
|
|
3
|
+
//#region src/app.d.ts
|
|
4
|
+
declare class ScheduleAppBootHook implements ILifecycleBoot {
|
|
5
|
+
private readonly app;
|
|
6
|
+
private readonly scheduleWorkerRegister;
|
|
7
|
+
private readonly scheduleWorkerLoadUnitHook;
|
|
8
|
+
private readonly schedulePrototypeHook;
|
|
9
|
+
constructor(app: Application);
|
|
10
|
+
configWillLoad(): void;
|
|
11
|
+
beforeClose(): Promise<void>;
|
|
10
12
|
}
|
|
13
|
+
//#endregion
|
|
14
|
+
export { ScheduleAppBootHook as default };
|
package/dist/app.js
CHANGED
|
@@ -1,24 +1,28 @@
|
|
|
1
|
-
import { ScheduleWorkerRegister } from "./lib/ScheduleWorkerRegister.js";
|
|
2
|
-
import { ScheduleWorkerLoadUnitHook } from "./lib/ScheduleWorkerLoadUnitHook.js";
|
|
3
1
|
import { SchedulePrototypeHook } from "./lib/SchedulePrototypeHook.js";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
2
|
+
import { ScheduleWorkerLoadUnitHook } from "./lib/ScheduleWorkerLoadUnitHook.js";
|
|
3
|
+
import { ScheduleWorkerRegister } from "./lib/ScheduleWorkerRegister.js";
|
|
4
|
+
|
|
5
|
+
//#region src/app.ts
|
|
6
|
+
var ScheduleAppBootHook = class {
|
|
7
|
+
app;
|
|
8
|
+
scheduleWorkerRegister;
|
|
9
|
+
scheduleWorkerLoadUnitHook;
|
|
10
|
+
schedulePrototypeHook;
|
|
11
|
+
constructor(app) {
|
|
12
|
+
this.app = app;
|
|
13
|
+
this.scheduleWorkerRegister = new ScheduleWorkerRegister(this.app);
|
|
14
|
+
this.scheduleWorkerLoadUnitHook = new ScheduleWorkerLoadUnitHook(this.scheduleWorkerRegister);
|
|
15
|
+
this.schedulePrototypeHook = new SchedulePrototypeHook();
|
|
16
|
+
}
|
|
17
|
+
configWillLoad() {
|
|
18
|
+
this.app.loadUnitLifecycleUtil.registerLifecycle(this.scheduleWorkerLoadUnitHook);
|
|
19
|
+
this.app.eggPrototypeLifecycleUtil.registerLifecycle(this.schedulePrototypeHook);
|
|
20
|
+
}
|
|
21
|
+
async beforeClose() {
|
|
22
|
+
this.app.loadUnitLifecycleUtil.deleteLifecycle(this.scheduleWorkerLoadUnitHook);
|
|
23
|
+
this.app.eggPrototypeLifecycleUtil.deleteLifecycle(this.schedulePrototypeHook);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
export { ScheduleAppBootHook as default };
|
package/dist/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import "./types.js";
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { EggPrototype } from "@eggjs/metadata";
|
|
2
|
+
import { ScheduleMetadata } from "@eggjs/schedule-decorator";
|
|
3
|
+
import { Context } from "egg";
|
|
4
|
+
|
|
5
|
+
//#region src/lib/EggScheduleAdapter.d.ts
|
|
6
|
+
type EggScheduleFunction = (ctx: Context, data: any) => Promise<any>;
|
|
7
|
+
declare function eggScheduleAdapterFactory(proto: EggPrototype, metaData: ScheduleMetadata<object>): EggScheduleFunction;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { EggScheduleFunction, eggScheduleAdapterFactory };
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import { ROOT_PROTO } from
|
|
2
|
-
import { EggContainerFactory } from
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
};
|
|
1
|
+
import { ROOT_PROTO } from "@eggjs/module-common";
|
|
2
|
+
import { EggContainerFactory } from "@eggjs/tegg-runtime";
|
|
3
|
+
|
|
4
|
+
//#region src/lib/EggScheduleAdapter.ts
|
|
5
|
+
function eggScheduleAdapterFactory(proto, metaData) {
|
|
6
|
+
return async function(ctx, data) {
|
|
7
|
+
ctx[ROOT_PROTO] = proto;
|
|
8
|
+
await ctx.beginModuleScope(async () => {
|
|
9
|
+
if (metaData.disable) return;
|
|
10
|
+
await (await EggContainerFactory.getOrCreateEggObject(proto, proto.name)).obj.subscribe(data);
|
|
11
|
+
});
|
|
12
|
+
};
|
|
14
13
|
}
|
|
15
|
-
|
|
14
|
+
|
|
15
|
+
//#endregion
|
|
16
|
+
export { eggScheduleAdapterFactory };
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { ScheduleMetadata } from "@eggjs/schedule-decorator";
|
|
2
|
+
import { EggAppConfig } from "egg";
|
|
3
|
+
|
|
4
|
+
//#region src/lib/EggScheduleMetadataConvertor.d.ts
|
|
5
|
+
type EggScheduleConfig = EggAppConfig["schedule"];
|
|
6
|
+
declare class EggScheduleMetadataConvertor {
|
|
7
|
+
/**
|
|
8
|
+
* convert to egg schedule config
|
|
9
|
+
*/
|
|
10
|
+
static convertToEggSchedule(metadata: ScheduleMetadata<object>): EggScheduleConfig;
|
|
9
11
|
}
|
|
10
|
-
|
|
12
|
+
//#endregion
|
|
13
|
+
export { EggScheduleMetadataConvertor };
|
|
@@ -1,16 +1,20 @@
|
|
|
1
|
-
import { ScheduleMetadata } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
|
|
1
|
+
import { ScheduleMetadata } from "@eggjs/schedule-decorator";
|
|
2
|
+
|
|
3
|
+
//#region src/lib/EggScheduleMetadataConvertor.ts
|
|
4
|
+
var EggScheduleMetadataConvertor = class {
|
|
5
|
+
/**
|
|
6
|
+
* convert to egg schedule config
|
|
7
|
+
*/
|
|
8
|
+
static convertToEggSchedule(metadata) {
|
|
9
|
+
return {
|
|
10
|
+
...metadata.scheduleData,
|
|
11
|
+
type: metadata.type,
|
|
12
|
+
env: metadata.env,
|
|
13
|
+
disable: metadata.disable,
|
|
14
|
+
immediate: metadata.immediate
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
//#endregion
|
|
20
|
+
export { EggScheduleMetadataConvertor };
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { EggPrototype, EggPrototypeLifecycleContext } from "@eggjs/metadata";
|
|
2
|
+
import { LifecycleHook } from "@eggjs/lifecycle";
|
|
3
|
+
|
|
4
|
+
//#region src/lib/SchedulePrototypeHook.d.ts
|
|
5
|
+
declare class SchedulePrototypeHook implements LifecycleHook<EggPrototypeLifecycleContext, EggPrototype> {
|
|
6
|
+
postCreate(ctx: EggPrototypeLifecycleContext): Promise<void>;
|
|
5
7
|
}
|
|
8
|
+
//#endregion
|
|
9
|
+
export { SchedulePrototypeHook };
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import { ScheduleInfoUtil,
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiU2NoZWR1bGVQcm90b3R5cGVIb29rLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2xpYi9TY2hlZHVsZVByb3RvdHlwZUhvb2sudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBRUEsT0FBTyxFQUFFLGdCQUFnQixFQUFFLG9CQUFvQixFQUFFLG1CQUFtQixFQUFFLE1BQU0sMkJBQTJCLENBQUM7QUFFeEcsTUFBTSxPQUFPLHFCQUFxQjtJQUNoQyxLQUFLLENBQUMsVUFBVSxDQUFDLEdBQWlDO1FBQ2hELElBQUksQ0FBQyxnQkFBZ0IsQ0FBQyxVQUFVLENBQUMsR0FBRyxDQUFDLEtBQUssQ0FBQyxFQUFFLENBQUM7WUFDNUMsT0FBTztRQUNULENBQUM7UUFDRCxNQUFNLE9BQU8sR0FBRyxJQUFJLG1CQUFtQixDQUFDLEdBQUcsQ0FBQyxLQUFLLENBQUMsQ0FBQztRQUNuRCxNQUFNLFFBQVEsR0FBRyxPQUFPLENBQUMsS0FBSyxFQUFFLENBQUM7UUFDakMsSUFBSSxRQUFRLEVBQUUsQ0FBQztZQUNiLG9CQUFvQixDQUFDLG1CQUFtQixDQUFDLEdBQUcsQ0FBQyxLQUFLLEVBQUUsUUFBUSxDQUFDLENBQUM7UUFDaEUsQ0FBQztJQUNILENBQUM7Q0FDRiJ9
|
|
1
|
+
import { ScheduleInfoUtil, ScheduleMetaBuilder, ScheduleMetadataUtil } from "@eggjs/schedule-decorator";
|
|
2
|
+
|
|
3
|
+
//#region src/lib/SchedulePrototypeHook.ts
|
|
4
|
+
var SchedulePrototypeHook = class {
|
|
5
|
+
async postCreate(ctx) {
|
|
6
|
+
if (!ScheduleInfoUtil.isSchedule(ctx.clazz)) return;
|
|
7
|
+
const metadata = new ScheduleMetaBuilder(ctx.clazz).build();
|
|
8
|
+
if (metadata) ScheduleMetadataUtil.setScheduleMetadata(ctx.clazz, metadata);
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
//#endregion
|
|
13
|
+
export { SchedulePrototypeHook };
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { ScheduleMetadata } from "@eggjs/schedule-decorator";
|
|
2
|
+
import { EggProtoImplClass } from "@eggjs/core-decorator";
|
|
3
|
+
import { Agent } from "egg";
|
|
4
|
+
|
|
5
|
+
//#region src/lib/ScheduleSubscriberRegister.d.ts
|
|
6
|
+
declare class ScheduleSubscriberRegister {
|
|
7
|
+
private readonly agent;
|
|
8
|
+
constructor(agent: Agent);
|
|
9
|
+
register(clazz: EggProtoImplClass<object>, metadata: ScheduleMetadata<object>): void;
|
|
8
10
|
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { ScheduleSubscriberRegister };
|
|
@@ -1,27 +1,26 @@
|
|
|
1
|
-
import { debuglog } from 'node:util';
|
|
2
|
-
import { PrototypeUtil } from '@eggjs/core-decorator';
|
|
3
|
-
import { ScheduleMetadata } from '@eggjs/schedule-decorator';
|
|
4
1
|
import { EggScheduleMetadataConvertor } from "./EggScheduleMetadataConvertor.js";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
|
|
2
|
+
import { ScheduleMetadata } from "@eggjs/schedule-decorator";
|
|
3
|
+
import { debuglog } from "node:util";
|
|
4
|
+
import { PrototypeUtil } from "@eggjs/core-decorator";
|
|
5
|
+
|
|
6
|
+
//#region src/lib/ScheduleSubscriberRegister.ts
|
|
7
|
+
const debug = debuglog("egg/tegg/plugin/schedule/ScheduleSubscriberRegister");
|
|
8
|
+
var ScheduleSubscriberRegister = class {
|
|
9
|
+
agent;
|
|
10
|
+
constructor(agent) {
|
|
11
|
+
this.agent = agent;
|
|
12
|
+
}
|
|
13
|
+
register(clazz, metadata) {
|
|
14
|
+
const schedule = EggScheduleMetadataConvertor.convertToEggSchedule(metadata);
|
|
15
|
+
const path = PrototypeUtil.getFilePath(clazz);
|
|
16
|
+
if (!metadata.disable) this.agent.logger.info("[@eggjs/schedule-plugin]: register schedule %s", path);
|
|
17
|
+
this.agent.schedule.registerSchedule({
|
|
18
|
+
schedule,
|
|
19
|
+
key: path
|
|
20
|
+
});
|
|
21
|
+
debug("register schedule %s, config: %j", path, schedule);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
//#endregion
|
|
26
|
+
export { ScheduleSubscriberRegister };
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { ScheduleWorkerRegister } from "./ScheduleWorkerRegister.js";
|
|
2
|
+
import { LoadUnit, LoadUnitLifecycleContext } from "@eggjs/metadata";
|
|
3
|
+
import { LifecycleHook } from "@eggjs/lifecycle";
|
|
4
|
+
|
|
5
|
+
//#region src/lib/ScheduleWorkerLoadUnitHook.d.ts
|
|
6
|
+
declare class ScheduleWorkerLoadUnitHook implements LifecycleHook<LoadUnitLifecycleContext, LoadUnit> {
|
|
7
|
+
private readonly scheduleWorkerRegister;
|
|
8
|
+
constructor(scheduleWorkerRegister: ScheduleWorkerRegister);
|
|
9
|
+
postCreate(_: LoadUnitLifecycleContext, obj: LoadUnit): Promise<void>;
|
|
8
10
|
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { ScheduleWorkerLoadUnitHook };
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { IS_SCHEDULE, SCHEDULE_METADATA } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
import { IS_SCHEDULE, SCHEDULE_METADATA } from "@eggjs/schedule-decorator";
|
|
2
|
+
|
|
3
|
+
//#region src/lib/ScheduleWorkerLoadUnitHook.ts
|
|
4
|
+
var ScheduleWorkerLoadUnitHook = class {
|
|
5
|
+
scheduleWorkerRegister;
|
|
6
|
+
constructor(scheduleWorkerRegister) {
|
|
7
|
+
this.scheduleWorkerRegister = scheduleWorkerRegister;
|
|
8
|
+
}
|
|
9
|
+
async postCreate(_, obj) {
|
|
10
|
+
const iterator = obj.iterateEggPrototype();
|
|
11
|
+
for (const proto of iterator) {
|
|
12
|
+
if (!proto.getMetaData(IS_SCHEDULE)) continue;
|
|
13
|
+
const metadata = proto.getMetaData(SCHEDULE_METADATA);
|
|
14
|
+
if (!metadata) continue;
|
|
15
|
+
this.scheduleWorkerRegister.register(proto, metadata);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
//#endregion
|
|
21
|
+
export { ScheduleWorkerLoadUnitHook };
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { EggPrototype } from "@eggjs/metadata";
|
|
2
|
+
import { ScheduleMetadata } from "@eggjs/schedule-decorator";
|
|
3
|
+
import { Application } from "egg";
|
|
4
|
+
|
|
5
|
+
//#region src/lib/ScheduleWorkerRegister.d.ts
|
|
6
|
+
declare class ScheduleWorkerRegister {
|
|
7
|
+
private readonly app;
|
|
8
|
+
constructor(app: Application);
|
|
9
|
+
register(proto: EggPrototype, metadata: ScheduleMetadata<object>): void;
|
|
8
10
|
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { ScheduleWorkerRegister };
|
|
@@ -1,25 +1,29 @@
|
|
|
1
|
-
import { debuglog } from 'node:util';
|
|
2
|
-
import { PrototypeUtil } from '@eggjs/core-decorator';
|
|
3
|
-
import { ScheduleMetadata } from '@eggjs/schedule-decorator';
|
|
4
|
-
import { eggScheduleAdapterFactory } from "./EggScheduleAdapter.js";
|
|
5
1
|
import { EggScheduleMetadataConvertor } from "./EggScheduleMetadataConvertor.js";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
2
|
+
import { eggScheduleAdapterFactory } from "./EggScheduleAdapter.js";
|
|
3
|
+
import { ScheduleMetadata } from "@eggjs/schedule-decorator";
|
|
4
|
+
import { debuglog } from "node:util";
|
|
5
|
+
import { PrototypeUtil } from "@eggjs/core-decorator";
|
|
6
|
+
|
|
7
|
+
//#region src/lib/ScheduleWorkerRegister.ts
|
|
8
|
+
const debug = debuglog("egg/tegg/plugin/schedule/ScheduleWorkerRegister");
|
|
9
|
+
var ScheduleWorkerRegister = class {
|
|
10
|
+
app;
|
|
11
|
+
constructor(app) {
|
|
12
|
+
this.app = app;
|
|
13
|
+
}
|
|
14
|
+
register(proto, metadata) {
|
|
15
|
+
const task = eggScheduleAdapterFactory(proto, metadata);
|
|
16
|
+
const schedule = EggScheduleMetadataConvertor.convertToEggSchedule(metadata);
|
|
17
|
+
const path = proto.getMetaData(PrototypeUtil.FILE_PATH);
|
|
18
|
+
this.app.scheduleWorker.registerSchedule({
|
|
19
|
+
schedule,
|
|
20
|
+
scheduleQueryString: "",
|
|
21
|
+
task,
|
|
22
|
+
key: path
|
|
23
|
+
});
|
|
24
|
+
debug("register schedule %s, config: %j", path, schedule);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
//#endregion
|
|
29
|
+
export { ScheduleWorkerRegister };
|
package/dist/types.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import "@eggjs/tegg-plugin/types";
|
package/dist/types.js
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import "@eggjs/tegg-plugin/types";
|
|
2
|
+
|
|
3
|
+
export { };
|
package/package.json
CHANGED
|
@@ -1,26 +1,31 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eggjs/schedule-plugin",
|
|
3
|
-
"
|
|
4
|
-
"name": "teggSchedule",
|
|
5
|
-
"dependencies": [
|
|
6
|
-
"tegg",
|
|
7
|
-
"schedule"
|
|
8
|
-
]
|
|
9
|
-
},
|
|
10
|
-
"version": "4.0.0-beta.34",
|
|
3
|
+
"version": "4.0.0-beta.36",
|
|
11
4
|
"description": "schedule decorator plugin for egg",
|
|
12
5
|
"keywords": [
|
|
13
6
|
"egg",
|
|
14
|
-
"plugin",
|
|
15
|
-
"typescript",
|
|
16
7
|
"module",
|
|
8
|
+
"plugin",
|
|
9
|
+
"schedule",
|
|
17
10
|
"tegg",
|
|
18
|
-
"
|
|
11
|
+
"typescript"
|
|
19
12
|
],
|
|
13
|
+
"homepage": "https://github.com/eggjs/egg/tree/next/tegg/plugin/schedule",
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/eggjs/egg/issues"
|
|
16
|
+
},
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git+https://github.com/eggjs/egg.git",
|
|
20
|
+
"directory": "tegg/plugin/schedule"
|
|
21
|
+
},
|
|
20
22
|
"files": [
|
|
21
23
|
"dist"
|
|
22
24
|
],
|
|
23
25
|
"type": "module",
|
|
26
|
+
"main": "./dist/index.js",
|
|
27
|
+
"module": "./dist/index.js",
|
|
28
|
+
"types": "./dist/index.d.ts",
|
|
24
29
|
"exports": {
|
|
25
30
|
".": "./dist/index.js",
|
|
26
31
|
"./agent": "./dist/agent.js",
|
|
@@ -34,53 +39,44 @@
|
|
|
34
39
|
"./types": "./dist/types.js",
|
|
35
40
|
"./package.json": "./package.json"
|
|
36
41
|
},
|
|
37
|
-
"
|
|
38
|
-
|
|
39
|
-
"url": "https://github.com/eggjs/egg/issues"
|
|
40
|
-
},
|
|
41
|
-
"repository": {
|
|
42
|
-
"type": "git",
|
|
43
|
-
"url": "git@github.com:eggjs/egg.git",
|
|
44
|
-
"directory": "tegg/plugin/schedule"
|
|
45
|
-
},
|
|
46
|
-
"engines": {
|
|
47
|
-
"node": ">=22.18.0"
|
|
42
|
+
"publishConfig": {
|
|
43
|
+
"access": "public"
|
|
48
44
|
},
|
|
49
45
|
"dependencies": {
|
|
50
|
-
"@eggjs/core-decorator": "4.0.0-beta.
|
|
51
|
-
"@eggjs/lifecycle": "4.0.0-beta.
|
|
52
|
-
"@eggjs/
|
|
53
|
-
"@eggjs/
|
|
54
|
-
"@eggjs/
|
|
55
|
-
"@eggjs/tegg-runtime": "4.0.0-beta.
|
|
56
|
-
"@eggjs/
|
|
57
|
-
},
|
|
58
|
-
"peerDependencies": {
|
|
59
|
-
"@eggjs/tegg-plugin": "4.0.0-beta.34",
|
|
60
|
-
"egg": "4.1.0-beta.34"
|
|
46
|
+
"@eggjs/core-decorator": "4.0.0-beta.36",
|
|
47
|
+
"@eggjs/lifecycle": "4.0.0-beta.36",
|
|
48
|
+
"@eggjs/metadata": "4.0.0-beta.36",
|
|
49
|
+
"@eggjs/module-common": "4.0.0-beta.36",
|
|
50
|
+
"@eggjs/schedule-decorator": "4.0.0-beta.36",
|
|
51
|
+
"@eggjs/tegg-runtime": "4.0.0-beta.36",
|
|
52
|
+
"@eggjs/tegg-loader": "4.0.0-beta.36"
|
|
61
53
|
},
|
|
62
54
|
"devDependencies": {
|
|
63
|
-
"@types/node": "^24.
|
|
64
|
-
"tsdown": "0.15.11",
|
|
55
|
+
"@types/node": "^24.10.2",
|
|
65
56
|
"typescript": "^5.9.3",
|
|
66
|
-
"
|
|
67
|
-
"@eggjs/mock": "7.0.0-beta.34",
|
|
57
|
+
"@eggjs/mock": "7.0.0-beta.36",
|
|
68
58
|
"@eggjs/module-test-util": "4.0.0-beta.29",
|
|
69
|
-
"@eggjs/tegg-common-util": "4.0.0-beta.
|
|
70
|
-
"@eggjs/tegg": "4.0.0-beta.
|
|
71
|
-
"@eggjs/tegg-config": "4.0.0-beta.
|
|
72
|
-
"
|
|
73
|
-
"
|
|
59
|
+
"@eggjs/tegg-common-util": "4.0.0-beta.36",
|
|
60
|
+
"@eggjs/tegg": "4.0.0-beta.36",
|
|
61
|
+
"@eggjs/tegg-config": "4.0.0-beta.36",
|
|
62
|
+
"egg": "4.1.0-beta.36",
|
|
63
|
+
"@eggjs/tegg-plugin": "4.0.0-beta.36"
|
|
74
64
|
},
|
|
75
|
-
"
|
|
76
|
-
"
|
|
65
|
+
"peerDependencies": {
|
|
66
|
+
"@eggjs/tegg-plugin": "4.0.0-beta.36",
|
|
67
|
+
"egg": "4.1.0-beta.36"
|
|
68
|
+
},
|
|
69
|
+
"engines": {
|
|
70
|
+
"node": ">=22.18.0"
|
|
71
|
+
},
|
|
72
|
+
"eggPlugin": {
|
|
73
|
+
"name": "teggSchedule",
|
|
74
|
+
"dependencies": [
|
|
75
|
+
"tegg",
|
|
76
|
+
"schedule"
|
|
77
|
+
]
|
|
77
78
|
},
|
|
78
|
-
"main": "./dist/index.js",
|
|
79
|
-
"module": "./dist/index.js",
|
|
80
|
-
"types": "./dist/index.d.ts",
|
|
81
79
|
"scripts": {
|
|
82
|
-
"
|
|
83
|
-
"build": "tsdown && rimraf dist *.tsbuildinfo && tsc -p tsconfig.build.json",
|
|
84
|
-
"typecheck": "tsc --noEmit"
|
|
80
|
+
"typecheck": "tsgo --noEmit"
|
|
85
81
|
}
|
|
86
82
|
}
|