@quark-fw/plugin-cron 0.1.26 → 0.1.28
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/package.json +5 -5
- package/src/CronScheduler.ts +4 -1
- package/src/index.ts +5 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quark-fw/plugin-cron",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.28",
|
|
4
4
|
"main": "src/index.ts",
|
|
5
5
|
"types": "src/index.ts",
|
|
6
6
|
"type": "module",
|
|
@@ -23,12 +23,12 @@
|
|
|
23
23
|
"access": "public"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@quark-fw/atom": "0.1.
|
|
27
|
-
"@quark-fw/plugin": "0.1.
|
|
26
|
+
"@quark-fw/atom": "0.1.28",
|
|
27
|
+
"@quark-fw/plugin": "0.1.28"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
|
-
"@quark-fw/core": "0.1.
|
|
31
|
-
"@quark-fw/plugin-redis": "0.1.
|
|
30
|
+
"@quark-fw/core": "0.1.28",
|
|
31
|
+
"@quark-fw/plugin-redis": "0.1.28",
|
|
32
32
|
"ioredis": "^5.9.3"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
package/src/CronScheduler.ts
CHANGED
|
@@ -12,6 +12,9 @@ import type {
|
|
|
12
12
|
CronJobOptions,
|
|
13
13
|
CronJobStatus,
|
|
14
14
|
} from "./types.js";
|
|
15
|
+
import { log as rootLog } from "@quark-fw/core/src/log.js";
|
|
16
|
+
|
|
17
|
+
const log = rootLog.child({ scope: "cron" });
|
|
15
18
|
|
|
16
19
|
// команды ioredis, которыми пользуется планировщик (тесты подсовывают фейк)
|
|
17
20
|
type RedisLike = Pick<Redis, "set" | "get" | "del" | "hset" | "hgetall">;
|
|
@@ -58,7 +61,7 @@ export class CronScheduler {
|
|
|
58
61
|
prefix = "quark:cron:",
|
|
59
62
|
tickMs = 20_000,
|
|
60
63
|
now = () => new Date(),
|
|
61
|
-
onError = (job, error) =>
|
|
64
|
+
onError = (job, error) => log.error("job failed", { job, err: error }),
|
|
62
65
|
}: CronSchedulerConfig) {
|
|
63
66
|
this.client = client;
|
|
64
67
|
this.prefix = prefix;
|
package/src/index.ts
CHANGED
|
@@ -2,6 +2,9 @@ import { QuarkPlugin } from "@quark-fw/plugin";
|
|
|
2
2
|
import {} from "@quark-fw/plugin-redis/src/global.js";
|
|
3
3
|
import {} from "@quark-fw/plugin-cron/src/global.js";
|
|
4
4
|
import { CronScheduler } from "./CronScheduler.js";
|
|
5
|
+
import { log as rootLog } from "@quark-fw/core/src/log.js";
|
|
6
|
+
|
|
7
|
+
const log = rootLog.child({ scope: "cron" });
|
|
5
8
|
|
|
6
9
|
export { CronScheduler } from "./CronScheduler.js";
|
|
7
10
|
export { parseCron, cronMatches } from "./cronExpression.js";
|
|
@@ -22,13 +25,11 @@ await quark.registerPlugin({
|
|
|
22
25
|
},
|
|
23
26
|
onReady(quark) {
|
|
24
27
|
if (process.env.CRON_DISABLED === "1") {
|
|
25
|
-
|
|
28
|
+
log.info("disabled (CRON_DISABLED=1)");
|
|
26
29
|
return;
|
|
27
30
|
}
|
|
28
31
|
quark.cron.start();
|
|
29
|
-
|
|
30
|
-
`[cron] scheduled: ${quark.cron.names().join(", ") || "(none)"}`,
|
|
31
|
-
);
|
|
32
|
+
log.info("scheduled", { jobs: quark.cron.names() });
|
|
32
33
|
},
|
|
33
34
|
onDestroy(quark) {
|
|
34
35
|
quark.cron.stop();
|