@sonamu-kit/tasks 0.0.1 → 0.0.2

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.
Files changed (69) hide show
  1. package/package.json +15 -15
  2. package/dist/errors.d.ts +0 -8
  3. package/dist/errors.d.ts.map +0 -1
  4. package/dist/errors.js +0 -21
  5. package/dist/errors.js.map +0 -1
  6. package/dist/practices/01-remote.d.ts +0 -2
  7. package/dist/practices/01-remote.d.ts.map +0 -1
  8. package/dist/practices/01-remote.js +0 -87
  9. package/dist/practices/01-remote.js.map +0 -1
  10. package/dist/practices/02-local.d.ts +0 -2
  11. package/dist/practices/02-local.d.ts.map +0 -1
  12. package/dist/practices/02-local.js +0 -84
  13. package/dist/practices/02-local.js.map +0 -1
  14. package/dist/practices/03-local-retry.d.ts +0 -2
  15. package/dist/practices/03-local-retry.d.ts.map +0 -1
  16. package/dist/practices/03-local-retry.js +0 -85
  17. package/dist/practices/03-local-retry.js.map +0 -1
  18. package/dist/practices/04-scheduler-dispose.d.ts +0 -2
  19. package/dist/practices/04-scheduler-dispose.d.ts.map +0 -1
  20. package/dist/practices/04-scheduler-dispose.js +0 -65
  21. package/dist/practices/04-scheduler-dispose.js.map +0 -1
  22. package/dist/practices/05-router.d.ts +0 -2
  23. package/dist/practices/05-router.d.ts.map +0 -1
  24. package/dist/practices/05-router.js +0 -80
  25. package/dist/practices/05-router.js.map +0 -1
  26. package/dist/scheduler.d.ts +0 -22
  27. package/dist/scheduler.d.ts.map +0 -1
  28. package/dist/scheduler.js +0 -117
  29. package/dist/scheduler.js.map +0 -1
  30. package/dist/tasks/index.d.ts +0 -4
  31. package/dist/tasks/index.d.ts.map +0 -1
  32. package/dist/tasks/index.js +0 -5
  33. package/dist/tasks/index.js.map +0 -1
  34. package/dist/tasks/local-task.d.ts +0 -6
  35. package/dist/tasks/local-task.d.ts.map +0 -1
  36. package/dist/tasks/local-task.js +0 -95
  37. package/dist/tasks/local-task.js.map +0 -1
  38. package/dist/tasks/remote-task.d.ts +0 -11
  39. package/dist/tasks/remote-task.d.ts.map +0 -1
  40. package/dist/tasks/remote-task.js +0 -213
  41. package/dist/tasks/remote-task.js.map +0 -1
  42. package/dist/tasks/shared.d.ts +0 -8
  43. package/dist/tasks/shared.d.ts.map +0 -1
  44. package/dist/tasks/shared.js +0 -41
  45. package/dist/tasks/shared.js.map +0 -1
  46. package/dist/types/config.d.ts +0 -44
  47. package/dist/types/config.d.ts.map +0 -1
  48. package/dist/types/config.js +0 -3
  49. package/dist/types/config.js.map +0 -1
  50. package/dist/types/context.d.ts +0 -18
  51. package/dist/types/context.d.ts.map +0 -1
  52. package/dist/types/context.js +0 -4
  53. package/dist/types/context.js.map +0 -1
  54. package/dist/types/events.d.ts +0 -43
  55. package/dist/types/events.d.ts.map +0 -1
  56. package/dist/types/events.js +0 -3
  57. package/dist/types/events.js.map +0 -1
  58. package/dist/types/index.d.ts +0 -6
  59. package/dist/types/index.d.ts.map +0 -1
  60. package/dist/types/index.js +0 -3
  61. package/dist/types/index.js.map +0 -1
  62. package/dist/types/task-items.d.ts +0 -12
  63. package/dist/types/task-items.d.ts.map +0 -1
  64. package/dist/types/task-items.js +0 -3
  65. package/dist/types/task-items.js.map +0 -1
  66. package/dist/types/utils.d.ts +0 -4
  67. package/dist/types/utils.d.ts.map +0 -1
  68. package/dist/types/utils.js +0 -8
  69. package/dist/types/utils.js.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sonamu-kit/tasks",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "type": "module",
5
5
  "description": "Sonamu Task - Simple & Distributed Task Queue",
6
6
  "main": "./dist/index.js",
@@ -16,17 +16,6 @@
16
16
  "development": "./src/internal.ts"
17
17
  }
18
18
  },
19
- "scripts": {
20
- "dev": "nodemon exec",
21
- "build": "swc src --config-file .swcrc -d dist --strip-leading-paths && tsc --emitDeclarationOnly",
22
- "check": "tsc --noEmit && biome format --write ./src/**/*.ts",
23
- "check:type": "tsc --noEmit",
24
- "check:format": "biome format --write ./src/**/*.ts",
25
- "pretest": "tsx scripts/migrate.ts",
26
- "test": "vitest run",
27
- "test:watch": "vitest watch --standalone",
28
- "test:coverage": "vitest run --coverage"
29
- },
30
19
  "author": "CartaNova <dev@cartanova.ai>",
31
20
  "repository": {
32
21
  "type": "git",
@@ -41,14 +30,14 @@
41
30
  "pg": "^8.16.3",
42
31
  "rou3": "^0.7.10",
43
32
  "uuid": "^13.0.0",
44
- "zod": "^4.1.12"
33
+ "zod": "^4.1.12",
34
+ "c12": "^3.3.2"
45
35
  },
46
36
  "devDependencies": {
47
37
  "@biomejs/biome": "^2.3.7",
48
38
  "@swc/cli": "^0.7.8",
49
39
  "@swc/core": "^1.15.3",
50
40
  "@types/node": "^24.9.2",
51
- "c12": "^3.3.2",
52
41
  "nodemon": "^3.1.10",
53
42
  "tsx": "^4.20.6",
54
43
  "typescript": "^5.9.3",
@@ -59,5 +48,16 @@
59
48
  },
60
49
  "optionalDependencies": {
61
50
  "pg-native": "^3.5.2"
51
+ },
52
+ "scripts": {
53
+ "dev": "nodemon exec",
54
+ "build": "swc src --config-file .swcrc -d dist --strip-leading-paths && tsc --emitDeclarationOnly",
55
+ "check": "tsc --noEmit && biome format --write ./src/**/*.ts",
56
+ "check:type": "tsc --noEmit",
57
+ "check:format": "biome format --write ./src/**/*.ts",
58
+ "pretest": "tsx scripts/migrate.ts",
59
+ "test": "vitest run",
60
+ "test:watch": "vitest watch --standalone",
61
+ "test:coverage": "vitest run --coverage"
62
62
  }
63
- }
63
+ }
package/dist/errors.d.ts DELETED
@@ -1,8 +0,0 @@
1
- import { ProcessErrorReasonEnum } from "./types";
2
- export declare class SonamuTaskError extends Error {
3
- cause: Error | undefined;
4
- type: ProcessErrorReasonEnum;
5
- constructor(type?: ProcessErrorReasonEnum, cause?: Error);
6
- }
7
- export declare function isSonamuTaskError(error: unknown): error is SonamuTaskError;
8
- //# sourceMappingURL=errors.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAEjD,qBAAa,eAAgB,SAAQ,KAAK;IACxC,KAAK,EAAE,KAAK,GAAG,SAAS,CAAC;IACzB,IAAI,EAAE,sBAAsB,CAAC;gBAEjB,IAAI,CAAC,EAAE,sBAAsB,EAAE,KAAK,CAAC,EAAE,KAAK;CAazD;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,eAAe,CAE1E"}
package/dist/errors.js DELETED
@@ -1,21 +0,0 @@
1
- export class SonamuTaskError extends Error {
2
- cause;
3
- type;
4
- constructor(type, cause){
5
- if (!type) {
6
- type = "exception";
7
- }
8
- super(`SonamuTaskError: ${type}`);
9
- this.name = "SonamuTaskError";
10
- this.type = type;
11
- if (cause) {
12
- this.cause = cause;
13
- this.stack = cause.stack;
14
- }
15
- }
16
- }
17
- export function isSonamuTaskError(error) {
18
- return error instanceof SonamuTaskError;
19
- }
20
-
21
- //# sourceMappingURL=errors.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/errors.ts"],"sourcesContent":["import { ProcessErrorReasonEnum } from \"./types\";\n\nexport class SonamuTaskError extends Error {\n cause: Error | undefined;\n type: ProcessErrorReasonEnum;\n\n constructor(type?: ProcessErrorReasonEnum, cause?: Error) {\n if (!type) {\n type = \"exception\";\n }\n\n super(`SonamuTaskError: ${type}`);\n this.name = \"SonamuTaskError\";\n this.type = type;\n if (cause) {\n this.cause = cause;\n this.stack = cause.stack;\n }\n }\n}\n\nexport function isSonamuTaskError(error: unknown): error is SonamuTaskError {\n return error instanceof SonamuTaskError;\n}\n"],"names":["SonamuTaskError","Error","cause","type","name","stack","isSonamuTaskError","error"],"mappings":"AAEA,OAAO,MAAMA,wBAAwBC;IACnCC,MAAyB;IACzBC,KAA6B;IAE7B,YAAYA,IAA6B,EAAED,KAAa,CAAE;QACxD,IAAI,CAACC,MAAM;YACTA,OAAO;QACT;QAEA,KAAK,CAAC,CAAC,iBAAiB,EAAEA,MAAM;QAChC,IAAI,CAACC,IAAI,GAAG;QACZ,IAAI,CAACD,IAAI,GAAGA;QACZ,IAAID,OAAO;YACT,IAAI,CAACA,KAAK,GAAGA;YACb,IAAI,CAACG,KAAK,GAAGH,MAAMG,KAAK;QAC1B;IACF;AACF;AAEA,OAAO,SAASC,kBAAkBC,KAAc;IAC9C,OAAOA,iBAAiBP;AAC1B"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=01-remote.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"01-remote.d.ts","sourceRoot":"","sources":["../../src/practices/01-remote.ts"],"names":[],"mappings":""}
@@ -1,87 +0,0 @@
1
- import { z } from "zod";
2
- import { createScheduler } from "../scheduler.js";
3
- import assert from "node:assert";
4
- function getConfig() {
5
- const schema = z.object();
6
- return {
7
- database: {
8
- client: "mysql2",
9
- pool: {
10
- min: 1,
11
- max: 5
12
- },
13
- connection: {
14
- database: "miomock",
15
- host: "0.0.0.0",
16
- port: 3306,
17
- user: "root",
18
- password: "miomock123",
19
- typeCast: function(field, next) {
20
- if (field.type === "TINY" && field.length === 1) {
21
- const value = field.string();
22
- return value ? value === "1" : null;
23
- }
24
- // DATE 타입은 문자열로 유지 (YYYY-MM-dd 형태)
25
- if (field.type === "DATE") {
26
- return field.string();
27
- }
28
- return next();
29
- }
30
- }
31
- },
32
- routes: [
33
- {
34
- path: "/test",
35
- schema: schema,
36
- target: async (ctx)=>{
37
- console.log("Processed", ctx);
38
- }
39
- },
40
- {
41
- path: "/test2",
42
- retry: {
43
- maxAttempts: 3,
44
- delay: {
45
- seconds: 1
46
- }
47
- },
48
- schema: schema,
49
- target: async ({ taskItem, retry })=>{
50
- if (taskItem.attempt !== retry.maxAttempts) {
51
- throw new Error("실패!");
52
- }
53
- }
54
- }
55
- ],
56
- retry: {
57
- delay: {},
58
- maxAttempts: 1
59
- },
60
- tasks: [
61
- {
62
- type: "remote",
63
- // node-cron은 초까지 지원하기 때문에 이렇게 10초마다 돌릴 수 있음.
64
- expression: "*/10 * * * * *",
65
- options: {
66
- timezone: "Asia/Seoul",
67
- name: "remote-job",
68
- noOverlap: false
69
- }
70
- }
71
- ]
72
- };
73
- }
74
- (async ()=>{
75
- const scheduler = await createScheduler(getConfig());
76
- // name이 *일 경우엔 모든 이벤트를 수신할 수 있음.
77
- scheduler.on("*", (evt)=>{
78
- console.log("Event: ", evt);
79
- });
80
- scheduler.on("process:start", (evt)=>{
81
- assert(evt.type === "process:start");
82
- console.log("[Process Started] Task Item: ", evt.task.id);
83
- });
84
- scheduler.start();
85
- })();
86
-
87
- //# sourceMappingURL=01-remote.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/practices/01-remote.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { createScheduler } from \"../scheduler\";\nimport type { TaskContext, SchedulerConfig, TaskEvent } from \"../types\";\nimport assert from \"node:assert\";\n\nfunction getConfig(): SchedulerConfig {\n const schema = z.object();\n\n return {\n database: {\n client: \"mysql2\",\n pool: { min: 1, max: 5 },\n connection: {\n database: \"miomock\",\n host: \"0.0.0.0\",\n port: 3306,\n user: \"root\",\n password: \"miomock123\",\n typeCast: function (field: any, next: any) {\n if (field.type === \"TINY\" && field.length === 1) {\n const value = field.string();\n return value ? value === \"1\" : null;\n }\n // DATE 타입은 문자열로 유지 (YYYY-MM-dd 형태)\n if (field.type === \"DATE\") {\n return field.string();\n }\n return next();\n },\n },\n },\n routes: [\n {\n path: \"/test\",\n schema: schema,\n target: async (ctx: TaskContext<typeof schema>) => {\n console.log(\"Processed\", ctx);\n },\n },\n {\n path: \"/test2\",\n retry: { maxAttempts: 3, delay: { seconds: 1 } },\n schema: schema,\n target: async ({ taskItem, retry }: TaskContext<typeof schema>) => {\n if (taskItem.attempt !== retry.maxAttempts) {\n throw new Error(\"실패!\");\n }\n },\n },\n ],\n\n retry: {\n delay: {},\n maxAttempts: 1,\n },\n\n tasks: [\n {\n type: \"remote\",\n // node-cron은 초까지 지원하기 때문에 이렇게 10초마다 돌릴 수 있음.\n expression: \"*/10 * * * * *\",\n options: {\n timezone: \"Asia/Seoul\",\n name: \"remote-job\",\n noOverlap: false,\n },\n },\n ],\n };\n}\n\n(async () => {\n const scheduler = await createScheduler(getConfig());\n\n // name이 *일 경우엔 모든 이벤트를 수신할 수 있음.\n scheduler.on(\"*\", (evt: TaskEvent) => {\n console.log(\"Event: \", evt);\n });\n\n scheduler.on(\"process:start\", (evt: TaskEvent) => {\n assert(evt.type === \"process:start\");\n console.log(\"[Process Started] Task Item: \", evt.task.id);\n });\n\n scheduler.start();\n})();\n"],"names":["z","createScheduler","assert","getConfig","schema","object","database","client","pool","min","max","connection","host","port","user","password","typeCast","field","next","type","length","value","string","routes","path","target","ctx","console","log","retry","maxAttempts","delay","seconds","taskItem","attempt","Error","tasks","expression","options","timezone","name","noOverlap","scheduler","on","evt","task","id","start"],"mappings":"AAAA,SAASA,CAAC,QAAQ,MAAM;AACxB,SAASC,eAAe,QAAQ,kBAAe;AAE/C,OAAOC,YAAY,cAAc;AAEjC,SAASC;IACP,MAAMC,SAASJ,EAAEK,MAAM;IAEvB,OAAO;QACLC,UAAU;YACRC,QAAQ;YACRC,MAAM;gBAAEC,KAAK;gBAAGC,KAAK;YAAE;YACvBC,YAAY;gBACVL,UAAU;gBACVM,MAAM;gBACNC,MAAM;gBACNC,MAAM;gBACNC,UAAU;gBACVC,UAAU,SAAUC,KAAU,EAAEC,IAAS;oBACvC,IAAID,MAAME,IAAI,KAAK,UAAUF,MAAMG,MAAM,KAAK,GAAG;wBAC/C,MAAMC,QAAQJ,MAAMK,MAAM;wBAC1B,OAAOD,QAAQA,UAAU,MAAM;oBACjC;oBACA,mCAAmC;oBACnC,IAAIJ,MAAME,IAAI,KAAK,QAAQ;wBACzB,OAAOF,MAAMK,MAAM;oBACrB;oBACA,OAAOJ;gBACT;YACF;QACF;QACAK,QAAQ;YACN;gBACEC,MAAM;gBACNpB,QAAQA;gBACRqB,QAAQ,OAAOC;oBACbC,QAAQC,GAAG,CAAC,aAAaF;gBAC3B;YACF;YACA;gBACEF,MAAM;gBACNK,OAAO;oBAAEC,aAAa;oBAAGC,OAAO;wBAAEC,SAAS;oBAAE;gBAAE;gBAC/C5B,QAAQA;gBACRqB,QAAQ,OAAO,EAAEQ,QAAQ,EAAEJ,KAAK,EAA8B;oBAC5D,IAAII,SAASC,OAAO,KAAKL,MAAMC,WAAW,EAAE;wBAC1C,MAAM,IAAIK,MAAM;oBAClB;gBACF;YACF;SACD;QAEDN,OAAO;YACLE,OAAO,CAAC;YACRD,aAAa;QACf;QAEAM,OAAO;YACL;gBACEjB,MAAM;gBACN,6CAA6C;gBAC7CkB,YAAY;gBACZC,SAAS;oBACPC,UAAU;oBACVC,MAAM;oBACNC,WAAW;gBACb;YACF;SACD;IACH;AACF;AAEC,CAAA;IACC,MAAMC,YAAY,MAAMzC,gBAAgBE;IAExC,iCAAiC;IACjCuC,UAAUC,EAAE,CAAC,KAAK,CAACC;QACjBjB,QAAQC,GAAG,CAAC,WAAWgB;IACzB;IAEAF,UAAUC,EAAE,CAAC,iBAAiB,CAACC;QAC7B1C,OAAO0C,IAAIzB,IAAI,KAAK;QACpBQ,QAAQC,GAAG,CAAC,iCAAiCgB,IAAIC,IAAI,CAACC,EAAE;IAC1D;IAEAJ,UAAUK,KAAK;AACjB,CAAA"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=02-local.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"02-local.d.ts","sourceRoot":"","sources":["../../src/practices/02-local.ts"],"names":[],"mappings":""}
@@ -1,84 +0,0 @@
1
- import { z } from "zod";
2
- import { createScheduler } from "../scheduler.js";
3
- function getConfig() {
4
- const schema = z.object();
5
- return {
6
- database: {
7
- client: "mysql2",
8
- pool: {
9
- min: 1,
10
- max: 5
11
- },
12
- connection: {
13
- database: "miomock",
14
- host: "0.0.0.0",
15
- port: 3306,
16
- user: "root",
17
- password: "miomock123",
18
- typeCast: function(field, next) {
19
- if (field.type === "TINY" && field.length === 1) {
20
- const value = field.string();
21
- return value ? value === "1" : null;
22
- }
23
- // DATE 타입은 문자열로 유지 (YYYY-MM-dd 형태)
24
- if (field.type === "DATE") {
25
- return field.string();
26
- }
27
- return next();
28
- }
29
- }
30
- },
31
- routes: [
32
- {
33
- path: "/test",
34
- schema: schema,
35
- target: async (ctx)=>{
36
- console.log("Processed", ctx);
37
- }
38
- },
39
- {
40
- path: "/test2",
41
- retry: {
42
- maxAttempts: 3,
43
- delay: {
44
- seconds: 1
45
- }
46
- },
47
- schema: schema,
48
- target: async ({ taskItem, retry })=>{
49
- // 마지막 시도에서만 성공하게 함.
50
- if (taskItem.attempt !== retry.maxAttempts) {
51
- throw new Error("실패!");
52
- }
53
- }
54
- }
55
- ],
56
- retry: {
57
- delay: {},
58
- maxAttempts: 1
59
- },
60
- tasks: [
61
- {
62
- type: "local",
63
- expression: "*/10 * * * * *",
64
- // local에서 실행할 때는 어느 namespace에서 어느 payload로 실행할지를 넣어야 함.
65
- payload: {},
66
- namespace: "/test2",
67
- // node-cron에서 쓰는 options를 공유함.
68
- options: {
69
- timezone: "Asia/Seoul",
70
- noOverlap: false
71
- }
72
- }
73
- ]
74
- };
75
- }
76
- (async ()=>{
77
- const scheduler = await createScheduler(getConfig());
78
- scheduler.on("*", (evt)=>{
79
- console.log("Event:", evt);
80
- });
81
- scheduler.start();
82
- })();
83
-
84
- //# sourceMappingURL=02-local.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/practices/02-local.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { createScheduler } from \"../scheduler\";\nimport type { TaskContext, SchedulerConfig, TaskEvent } from \"../types\";\n\nfunction getConfig(): SchedulerConfig {\n const schema = z.object();\n\n return {\n database: {\n client: \"mysql2\",\n pool: { min: 1, max: 5 },\n connection: {\n database: \"miomock\",\n host: \"0.0.0.0\",\n port: 3306,\n user: \"root\",\n password: \"miomock123\",\n typeCast: function (field: any, next: any) {\n if (field.type === \"TINY\" && field.length === 1) {\n const value = field.string();\n return value ? value === \"1\" : null;\n }\n // DATE 타입은 문자열로 유지 (YYYY-MM-dd 형태)\n if (field.type === \"DATE\") {\n return field.string();\n }\n return next();\n },\n },\n },\n routes: [\n {\n path: \"/test\",\n schema: schema,\n target: async (ctx: TaskContext<typeof schema>) => {\n console.log(\"Processed\", ctx);\n },\n },\n {\n path: \"/test2\",\n retry: { maxAttempts: 3, delay: { seconds: 1 } },\n schema: schema,\n target: async ({ taskItem, retry }: TaskContext<typeof schema>) => {\n // 마지막 시도에서만 성공하게 함.\n if (taskItem.attempt !== retry.maxAttempts) {\n throw new Error(\"실패!\");\n }\n },\n },\n ],\n\n retry: {\n delay: {},\n maxAttempts: 1,\n },\n\n tasks: [\n {\n type: \"local\",\n expression: \"*/10 * * * * *\",\n\n // local에서 실행할 때는 어느 namespace에서 어느 payload로 실행할지를 넣어야 함.\n payload: {},\n namespace: \"/test2\",\n\n // node-cron에서 쓰는 options를 공유함.\n options: {\n timezone: \"Asia/Seoul\",\n noOverlap: false,\n },\n },\n ],\n };\n}\n\n(async () => {\n const scheduler = await createScheduler(getConfig());\n scheduler.on(\"*\", (evt: TaskEvent) => {\n console.log(\"Event:\", evt);\n });\n\n scheduler.start();\n})();\n"],"names":["z","createScheduler","getConfig","schema","object","database","client","pool","min","max","connection","host","port","user","password","typeCast","field","next","type","length","value","string","routes","path","target","ctx","console","log","retry","maxAttempts","delay","seconds","taskItem","attempt","Error","tasks","expression","payload","namespace","options","timezone","noOverlap","scheduler","on","evt","start"],"mappings":"AAAA,SAASA,CAAC,QAAQ,MAAM;AACxB,SAASC,eAAe,QAAQ,kBAAe;AAG/C,SAASC;IACP,MAAMC,SAASH,EAAEI,MAAM;IAEvB,OAAO;QACLC,UAAU;YACRC,QAAQ;YACRC,MAAM;gBAAEC,KAAK;gBAAGC,KAAK;YAAE;YACvBC,YAAY;gBACVL,UAAU;gBACVM,MAAM;gBACNC,MAAM;gBACNC,MAAM;gBACNC,UAAU;gBACVC,UAAU,SAAUC,KAAU,EAAEC,IAAS;oBACvC,IAAID,MAAME,IAAI,KAAK,UAAUF,MAAMG,MAAM,KAAK,GAAG;wBAC/C,MAAMC,QAAQJ,MAAMK,MAAM;wBAC1B,OAAOD,QAAQA,UAAU,MAAM;oBACjC;oBACA,mCAAmC;oBACnC,IAAIJ,MAAME,IAAI,KAAK,QAAQ;wBACzB,OAAOF,MAAMK,MAAM;oBACrB;oBACA,OAAOJ;gBACT;YACF;QACF;QACAK,QAAQ;YACN;gBACEC,MAAM;gBACNpB,QAAQA;gBACRqB,QAAQ,OAAOC;oBACbC,QAAQC,GAAG,CAAC,aAAaF;gBAC3B;YACF;YACA;gBACEF,MAAM;gBACNK,OAAO;oBAAEC,aAAa;oBAAGC,OAAO;wBAAEC,SAAS;oBAAE;gBAAE;gBAC/C5B,QAAQA;gBACRqB,QAAQ,OAAO,EAAEQ,QAAQ,EAAEJ,KAAK,EAA8B;oBAC5D,oBAAoB;oBACpB,IAAII,SAASC,OAAO,KAAKL,MAAMC,WAAW,EAAE;wBAC1C,MAAM,IAAIK,MAAM;oBAClB;gBACF;YACF;SACD;QAEDN,OAAO;YACLE,OAAO,CAAC;YACRD,aAAa;QACf;QAEAM,OAAO;YACL;gBACEjB,MAAM;gBACNkB,YAAY;gBAEZ,yDAAyD;gBACzDC,SAAS,CAAC;gBACVC,WAAW;gBAEX,+BAA+B;gBAC/BC,SAAS;oBACPC,UAAU;oBACVC,WAAW;gBACb;YACF;SACD;IACH;AACF;AAEC,CAAA;IACC,MAAMC,YAAY,MAAMzC,gBAAgBC;IACxCwC,UAAUC,EAAE,CAAC,KAAK,CAACC;QACjBlB,QAAQC,GAAG,CAAC,UAAUiB;IACxB;IAEAF,UAAUG,KAAK;AACjB,CAAA"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=03-local-retry.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"03-local-retry.d.ts","sourceRoot":"","sources":["../../src/practices/03-local-retry.ts"],"names":[],"mappings":""}
@@ -1,85 +0,0 @@
1
- import { z } from "zod";
2
- import { createScheduler } from "../scheduler.js";
3
- function getConfig() {
4
- const schema = z.object();
5
- return {
6
- database: {
7
- client: "mysql2",
8
- pool: {
9
- min: 1,
10
- max: 5
11
- },
12
- connection: {
13
- database: "miomock",
14
- host: "0.0.0.0",
15
- port: 3306,
16
- user: "root",
17
- password: "miomock123",
18
- typeCast: function(field, next) {
19
- if (field.type === "TINY" && field.length === 1) {
20
- const value = field.string();
21
- return value ? value === "1" : null;
22
- }
23
- // DATE 타입은 문자열로 유지 (YYYY-MM-dd 형태)
24
- if (field.type === "DATE") {
25
- return field.string();
26
- }
27
- return next();
28
- }
29
- }
30
- },
31
- routes: [
32
- {
33
- path: "/test",
34
- schema: schema,
35
- target: async (ctx)=>{
36
- console.log("Processed", ctx);
37
- }
38
- },
39
- {
40
- path: "/test2",
41
- retry: {
42
- maxAttempts: 3,
43
- // delay는 함수로 넘겨서 Exponential Backoff 등을 구현할 수 있음.
44
- delay: (attempt)=>{
45
- return {
46
- seconds: Math.pow(3, attempt)
47
- };
48
- }
49
- },
50
- schema: schema,
51
- target: async ({ taskItem, retry })=>{
52
- console.log(`Attempt: ${taskItem.attempt}, Max Attempts: ${retry.maxAttempts}, Time: ${new Date()}`);
53
- // 마지막 시도에서만 성공하게 함.
54
- if (taskItem.attempt !== retry.maxAttempts) {
55
- throw new Error("실패!");
56
- }
57
- }
58
- }
59
- ],
60
- retry: {
61
- delay: {},
62
- maxAttempts: 1
63
- },
64
- tasks: [
65
- {
66
- type: "local",
67
- expression: "*/10 * * * * *",
68
- // local에서 실행할 때는 어느 namespace에서 어느 payload로 실행할지를 넣어야 함.
69
- payload: {},
70
- namespace: "/test2",
71
- // node-cron에서 쓰는 options를 공유함.
72
- options: {
73
- timezone: "Asia/Seoul",
74
- noOverlap: false
75
- }
76
- }
77
- ]
78
- };
79
- }
80
- (async ()=>{
81
- const scheduler = await createScheduler(getConfig());
82
- scheduler.start();
83
- })();
84
-
85
- //# sourceMappingURL=03-local-retry.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/practices/03-local-retry.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { createScheduler } from \"../scheduler\";\nimport type { TaskContext, SchedulerConfig } from \"../types\";\n\nfunction getConfig(): SchedulerConfig {\n const schema = z.object();\n\n return {\n database: {\n client: \"mysql2\",\n pool: { min: 1, max: 5 },\n connection: {\n database: \"miomock\",\n host: \"0.0.0.0\",\n port: 3306,\n user: \"root\",\n password: \"miomock123\",\n typeCast: function (field: any, next: any) {\n if (field.type === \"TINY\" && field.length === 1) {\n const value = field.string();\n return value ? value === \"1\" : null;\n }\n // DATE 타입은 문자열로 유지 (YYYY-MM-dd 형태)\n if (field.type === \"DATE\") {\n return field.string();\n }\n return next();\n },\n },\n },\n routes: [\n {\n path: \"/test\",\n schema: schema,\n target: async (ctx: TaskContext<typeof schema>) => {\n console.log(\"Processed\", ctx);\n },\n },\n {\n path: \"/test2\",\n retry: {\n maxAttempts: 3,\n // delay는 함수로 넘겨서 Exponential Backoff 등을 구현할 수 있음.\n delay: (attempt: number) => {\n return { seconds: Math.pow(3, attempt) };\n },\n },\n schema: schema,\n target: async ({ taskItem, retry }: TaskContext<typeof schema>) => {\n console.log(\n `Attempt: ${taskItem.attempt}, Max Attempts: ${retry.maxAttempts}, Time: ${new Date()}`,\n );\n\n // 마지막 시도에서만 성공하게 함.\n if (taskItem.attempt !== retry.maxAttempts) {\n throw new Error(\"실패!\");\n }\n },\n },\n ],\n\n retry: {\n delay: {},\n maxAttempts: 1,\n },\n\n tasks: [\n {\n type: \"local\",\n expression: \"*/10 * * * * *\",\n\n // local에서 실행할 때는 어느 namespace에서 어느 payload로 실행할지를 넣어야 함.\n payload: {},\n namespace: \"/test2\",\n\n // node-cron에서 쓰는 options를 공유함.\n options: {\n timezone: \"Asia/Seoul\",\n noOverlap: false,\n },\n },\n ],\n };\n}\n\n(async () => {\n const scheduler = await createScheduler(getConfig());\n scheduler.start();\n})();\n"],"names":["z","createScheduler","getConfig","schema","object","database","client","pool","min","max","connection","host","port","user","password","typeCast","field","next","type","length","value","string","routes","path","target","ctx","console","log","retry","maxAttempts","delay","attempt","seconds","Math","pow","taskItem","Date","Error","tasks","expression","payload","namespace","options","timezone","noOverlap","scheduler","start"],"mappings":"AAAA,SAASA,CAAC,QAAQ,MAAM;AACxB,SAASC,eAAe,QAAQ,kBAAe;AAG/C,SAASC;IACP,MAAMC,SAASH,EAAEI,MAAM;IAEvB,OAAO;QACLC,UAAU;YACRC,QAAQ;YACRC,MAAM;gBAAEC,KAAK;gBAAGC,KAAK;YAAE;YACvBC,YAAY;gBACVL,UAAU;gBACVM,MAAM;gBACNC,MAAM;gBACNC,MAAM;gBACNC,UAAU;gBACVC,UAAU,SAAUC,KAAU,EAAEC,IAAS;oBACvC,IAAID,MAAME,IAAI,KAAK,UAAUF,MAAMG,MAAM,KAAK,GAAG;wBAC/C,MAAMC,QAAQJ,MAAMK,MAAM;wBAC1B,OAAOD,QAAQA,UAAU,MAAM;oBACjC;oBACA,mCAAmC;oBACnC,IAAIJ,MAAME,IAAI,KAAK,QAAQ;wBACzB,OAAOF,MAAMK,MAAM;oBACrB;oBACA,OAAOJ;gBACT;YACF;QACF;QACAK,QAAQ;YACN;gBACEC,MAAM;gBACNpB,QAAQA;gBACRqB,QAAQ,OAAOC;oBACbC,QAAQC,GAAG,CAAC,aAAaF;gBAC3B;YACF;YACA;gBACEF,MAAM;gBACNK,OAAO;oBACLC,aAAa;oBACb,kDAAkD;oBAClDC,OAAO,CAACC;wBACN,OAAO;4BAAEC,SAASC,KAAKC,GAAG,CAAC,GAAGH;wBAAS;oBACzC;gBACF;gBACA5B,QAAQA;gBACRqB,QAAQ,OAAO,EAAEW,QAAQ,EAAEP,KAAK,EAA8B;oBAC5DF,QAAQC,GAAG,CACT,CAAC,SAAS,EAAEQ,SAASJ,OAAO,CAAC,gBAAgB,EAAEH,MAAMC,WAAW,CAAC,QAAQ,EAAE,IAAIO,QAAQ;oBAGzF,oBAAoB;oBACpB,IAAID,SAASJ,OAAO,KAAKH,MAAMC,WAAW,EAAE;wBAC1C,MAAM,IAAIQ,MAAM;oBAClB;gBACF;YACF;SACD;QAEDT,OAAO;YACLE,OAAO,CAAC;YACRD,aAAa;QACf;QAEAS,OAAO;YACL;gBACEpB,MAAM;gBACNqB,YAAY;gBAEZ,yDAAyD;gBACzDC,SAAS,CAAC;gBACVC,WAAW;gBAEX,+BAA+B;gBAC/BC,SAAS;oBACPC,UAAU;oBACVC,WAAW;gBACb;YACF;SACD;IACH;AACF;AAEC,CAAA;IACC,MAAMC,YAAY,MAAM5C,gBAAgBC;IACxC2C,UAAUC,KAAK;AACjB,CAAA"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=04-scheduler-dispose.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"04-scheduler-dispose.d.ts","sourceRoot":"","sources":["../../src/practices/04-scheduler-dispose.ts"],"names":[],"mappings":""}
@@ -1,65 +0,0 @@
1
- import { z } from "zod";
2
- import { createScheduler } from "../scheduler.js";
3
- function getConfig() {
4
- const schema = z.object();
5
- return {
6
- database: {
7
- client: "mysql2",
8
- pool: {
9
- min: 1,
10
- max: 5
11
- },
12
- connection: {
13
- database: "miomock",
14
- host: "0.0.0.0",
15
- port: 3306,
16
- user: "root",
17
- password: "miomock123",
18
- typeCast: function(field, next) {
19
- if (field.type === "TINY" && field.length === 1) {
20
- const value = field.string();
21
- return value ? value === "1" : null;
22
- }
23
- // DATE 타입은 문자열로 유지 (YYYY-MM-dd 형태)
24
- if (field.type === "DATE") {
25
- return field.string();
26
- }
27
- return next();
28
- }
29
- }
30
- },
31
- routes: [
32
- {
33
- path: "/test",
34
- schema: schema,
35
- target: async (ctx)=>{
36
- console.log("Processed", ctx);
37
- }
38
- }
39
- ],
40
- retry: {
41
- delay: {},
42
- maxAttempts: 1
43
- },
44
- tasks: [
45
- {
46
- type: "remote",
47
- expression: "5 * * * *",
48
- options: {
49
- timezone: "Asia/Seoul",
50
- noOverlap: false
51
- }
52
- }
53
- ]
54
- };
55
- }
56
- // scheduler를 dispose하면 대기 중인 Promise가 없기 때문에 프로그램은 1분 뒤에 바로 종료된다.
57
- (async ()=>{
58
- const scheduler = await createScheduler(getConfig());
59
- setTimeout(()=>{
60
- scheduler.dispose();
61
- }, 60 * 1000);
62
- scheduler.start();
63
- })();
64
-
65
- //# sourceMappingURL=04-scheduler-dispose.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/practices/04-scheduler-dispose.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { createScheduler } from \"../scheduler\";\nimport type { TaskContext, SchedulerConfig } from \"../types\";\n\nfunction getConfig(): SchedulerConfig {\n const schema = z.object();\n\n return {\n database: {\n client: \"mysql2\",\n pool: { min: 1, max: 5 },\n connection: {\n database: \"miomock\",\n host: \"0.0.0.0\",\n port: 3306,\n user: \"root\",\n password: \"miomock123\",\n typeCast: function (field: any, next: any) {\n if (field.type === \"TINY\" && field.length === 1) {\n const value = field.string();\n return value ? value === \"1\" : null;\n }\n // DATE 타입은 문자열로 유지 (YYYY-MM-dd 형태)\n if (field.type === \"DATE\") {\n return field.string();\n }\n return next();\n },\n },\n },\n routes: [\n {\n path: \"/test\",\n schema: schema,\n target: async (ctx: TaskContext<typeof schema>) => {\n console.log(\"Processed\", ctx);\n },\n },\n ],\n\n retry: {\n delay: {},\n maxAttempts: 1,\n },\n\n tasks: [\n {\n type: \"remote\",\n expression: \"5 * * * *\",\n options: {\n timezone: \"Asia/Seoul\",\n noOverlap: false,\n },\n },\n ],\n };\n}\n// scheduler를 dispose하면 대기 중인 Promise가 없기 때문에 프로그램은 1분 뒤에 바로 종료된다.\n(async () => {\n const scheduler = await createScheduler(getConfig());\n setTimeout(() => {\n scheduler.dispose();\n }, 60 * 1000);\n\n scheduler.start();\n})();\n"],"names":["z","createScheduler","getConfig","schema","object","database","client","pool","min","max","connection","host","port","user","password","typeCast","field","next","type","length","value","string","routes","path","target","ctx","console","log","retry","delay","maxAttempts","tasks","expression","options","timezone","noOverlap","scheduler","setTimeout","dispose","start"],"mappings":"AAAA,SAASA,CAAC,QAAQ,MAAM;AACxB,SAASC,eAAe,QAAQ,kBAAe;AAG/C,SAASC;IACP,MAAMC,SAASH,EAAEI,MAAM;IAEvB,OAAO;QACLC,UAAU;YACRC,QAAQ;YACRC,MAAM;gBAAEC,KAAK;gBAAGC,KAAK;YAAE;YACvBC,YAAY;gBACVL,UAAU;gBACVM,MAAM;gBACNC,MAAM;gBACNC,MAAM;gBACNC,UAAU;gBACVC,UAAU,SAAUC,KAAU,EAAEC,IAAS;oBACvC,IAAID,MAAME,IAAI,KAAK,UAAUF,MAAMG,MAAM,KAAK,GAAG;wBAC/C,MAAMC,QAAQJ,MAAMK,MAAM;wBAC1B,OAAOD,QAAQA,UAAU,MAAM;oBACjC;oBACA,mCAAmC;oBACnC,IAAIJ,MAAME,IAAI,KAAK,QAAQ;wBACzB,OAAOF,MAAMK,MAAM;oBACrB;oBACA,OAAOJ;gBACT;YACF;QACF;QACAK,QAAQ;YACN;gBACEC,MAAM;gBACNpB,QAAQA;gBACRqB,QAAQ,OAAOC;oBACbC,QAAQC,GAAG,CAAC,aAAaF;gBAC3B;YACF;SACD;QAEDG,OAAO;YACLC,OAAO,CAAC;YACRC,aAAa;QACf;QAEAC,OAAO;YACL;gBACEb,MAAM;gBACNc,YAAY;gBACZC,SAAS;oBACPC,UAAU;oBACVC,WAAW;gBACb;YACF;SACD;IACH;AACF;AACA,kEAAkE;AACjE,CAAA;IACC,MAAMC,YAAY,MAAMnC,gBAAgBC;IACxCmC,WAAW;QACTD,UAAUE,OAAO;IACnB,GAAG,KAAK;IAERF,UAAUG,KAAK;AACjB,CAAA"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=05-router.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"05-router.d.ts","sourceRoot":"","sources":["../../src/practices/05-router.ts"],"names":[],"mappings":""}
@@ -1,80 +0,0 @@
1
- import { z } from "zod";
2
- import { createScheduler } from "../scheduler.js";
3
- function getConfig() {
4
- const schema = z.object();
5
- return {
6
- database: {
7
- client: "mysql2",
8
- pool: {
9
- min: 1,
10
- max: 5
11
- },
12
- connection: {
13
- database: "miomock",
14
- host: "0.0.0.0",
15
- port: 3306,
16
- user: "root",
17
- password: "miomock123",
18
- typeCast: function(field, next) {
19
- if (field.type === "TINY" && field.length === 1) {
20
- const value = field.string();
21
- return value ? value === "1" : null;
22
- }
23
- // DATE 타입은 문자열로 유지 (YYYY-MM-dd 형태)
24
- if (field.type === "DATE") {
25
- return field.string();
26
- }
27
- return next();
28
- }
29
- }
30
- },
31
- routes: [
32
- {
33
- path: "/test",
34
- schema: schema,
35
- target: async (ctx)=>{
36
- console.log("Processed", ctx);
37
- }
38
- },
39
- {
40
- // rou3을 쓰기 때문에, task의 path는 HTTP Router 문법에 대응됨.
41
- path: "/test/:complexId",
42
- retry: {
43
- maxAttempts: 3,
44
- delay: {
45
- seconds: 1
46
- }
47
- },
48
- schema: schema,
49
- target: async ({ params })=>{
50
- // router를 통해 complexId가 전달됨.
51
- console.log(params?.complexId);
52
- }
53
- }
54
- ],
55
- retry: {
56
- delay: {},
57
- maxAttempts: 1
58
- },
59
- tasks: [
60
- {
61
- type: "local",
62
- expression: "*/10 * * * * *",
63
- // rou3을 쓰기 때문에, task의 path는 HTTP Router 문법에 대응됨.
64
- namespace: "/test/some-complex-data",
65
- payload: {},
66
- options: {
67
- timezone: "Asia/Seoul",
68
- name: "local-router-test",
69
- noOverlap: false
70
- }
71
- }
72
- ]
73
- };
74
- }
75
- (async ()=>{
76
- const scheduler = await createScheduler(getConfig());
77
- scheduler.start();
78
- })();
79
-
80
- //# sourceMappingURL=05-router.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/practices/05-router.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { createScheduler } from \"../scheduler\";\nimport type { TaskContext, SchedulerConfig } from \"../types\";\n\nfunction getConfig(): SchedulerConfig {\n const schema = z.object();\n\n return {\n database: {\n client: \"mysql2\",\n pool: { min: 1, max: 5 },\n connection: {\n database: \"miomock\",\n host: \"0.0.0.0\",\n port: 3306,\n user: \"root\",\n password: \"miomock123\",\n typeCast: function (field: any, next: any) {\n if (field.type === \"TINY\" && field.length === 1) {\n const value = field.string();\n return value ? value === \"1\" : null;\n }\n // DATE 타입은 문자열로 유지 (YYYY-MM-dd 형태)\n if (field.type === \"DATE\") {\n return field.string();\n }\n return next();\n },\n },\n },\n routes: [\n {\n path: \"/test\",\n schema: schema,\n target: async (ctx: TaskContext<typeof schema>) => {\n console.log(\"Processed\", ctx);\n },\n },\n {\n // rou3을 쓰기 때문에, task의 path는 HTTP Router 문법에 대응됨.\n path: \"/test/:complexId\",\n retry: { maxAttempts: 3, delay: { seconds: 1 } },\n schema: schema,\n target: async ({ params }: TaskContext<typeof schema>) => {\n // router를 통해 complexId가 전달됨.\n console.log(params?.complexId);\n },\n },\n ],\n\n retry: {\n delay: {},\n maxAttempts: 1,\n },\n\n tasks: [\n {\n type: \"local\",\n expression: \"*/10 * * * * *\",\n // rou3을 쓰기 때문에, task의 path는 HTTP Router 문법에 대응됨.\n namespace: \"/test/some-complex-data\",\n payload: {},\n options: {\n timezone: \"Asia/Seoul\",\n name: \"local-router-test\",\n noOverlap: false,\n },\n },\n ],\n };\n}\n\n(async () => {\n const scheduler = await createScheduler(getConfig());\n scheduler.start();\n})();\n"],"names":["z","createScheduler","getConfig","schema","object","database","client","pool","min","max","connection","host","port","user","password","typeCast","field","next","type","length","value","string","routes","path","target","ctx","console","log","retry","maxAttempts","delay","seconds","params","complexId","tasks","expression","namespace","payload","options","timezone","name","noOverlap","scheduler","start"],"mappings":"AAAA,SAASA,CAAC,QAAQ,MAAM;AACxB,SAASC,eAAe,QAAQ,kBAAe;AAG/C,SAASC;IACP,MAAMC,SAASH,EAAEI,MAAM;IAEvB,OAAO;QACLC,UAAU;YACRC,QAAQ;YACRC,MAAM;gBAAEC,KAAK;gBAAGC,KAAK;YAAE;YACvBC,YAAY;gBACVL,UAAU;gBACVM,MAAM;gBACNC,MAAM;gBACNC,MAAM;gBACNC,UAAU;gBACVC,UAAU,SAAUC,KAAU,EAAEC,IAAS;oBACvC,IAAID,MAAME,IAAI,KAAK,UAAUF,MAAMG,MAAM,KAAK,GAAG;wBAC/C,MAAMC,QAAQJ,MAAMK,MAAM;wBAC1B,OAAOD,QAAQA,UAAU,MAAM;oBACjC;oBACA,mCAAmC;oBACnC,IAAIJ,MAAME,IAAI,KAAK,QAAQ;wBACzB,OAAOF,MAAMK,MAAM;oBACrB;oBACA,OAAOJ;gBACT;YACF;QACF;QACAK,QAAQ;YACN;gBACEC,MAAM;gBACNpB,QAAQA;gBACRqB,QAAQ,OAAOC;oBACbC,QAAQC,GAAG,CAAC,aAAaF;gBAC3B;YACF;YACA;gBACE,iDAAiD;gBACjDF,MAAM;gBACNK,OAAO;oBAAEC,aAAa;oBAAGC,OAAO;wBAAEC,SAAS;oBAAE;gBAAE;gBAC/C5B,QAAQA;gBACRqB,QAAQ,OAAO,EAAEQ,MAAM,EAA8B;oBACnD,6BAA6B;oBAC7BN,QAAQC,GAAG,CAACK,QAAQC;gBACtB;YACF;SACD;QAEDL,OAAO;YACLE,OAAO,CAAC;YACRD,aAAa;QACf;QAEAK,OAAO;YACL;gBACEhB,MAAM;gBACNiB,YAAY;gBACZ,iDAAiD;gBACjDC,WAAW;gBACXC,SAAS,CAAC;gBACVC,SAAS;oBACPC,UAAU;oBACVC,MAAM;oBACNC,WAAW;gBACb;YACF;SACD;IACH;AACF;AAEC,CAAA;IACC,MAAMC,YAAY,MAAMzC,gBAAgBC;IACxCwC,UAAUC,KAAK;AACjB,CAAA"}
@@ -1,22 +0,0 @@
1
- import { type Knex } from "knex";
2
- import { type RouterContext } from "rou3";
3
- import { type EventType, type LocalTaskConfig, type SchedulerInfo, type OnEventFunction, type RemoteTaskConfig, type Resolvable, type RetryConfig, type SchedulerConfig, type TaskRouterContext } from "./types";
4
- export declare class SonamuScheduler {
5
- #private;
6
- readonly info: SchedulerInfo;
7
- constructor(knex: Knex, router: RouterContext<TaskRouterContext & {
8
- info: SchedulerInfo;
9
- }>, info: SchedulerInfo, retry?: RetryConfig);
10
- [Symbol.asyncDispose](): Promise<void>;
11
- addRoute(...routes: (Omit<TaskRouterContext, "retry"> & {
12
- retry?: RetryConfig;
13
- })[]): void;
14
- addTask(...tasks: (RemoteTaskConfig | LocalTaskConfig)[]): void;
15
- start(): void;
16
- stop(): void;
17
- dispose(): Promise<void>;
18
- on(name: EventType | "*", fn: OnEventFunction): void;
19
- off(name: EventType | "*", fn: OnEventFunction): void;
20
- }
21
- export declare function createScheduler(input: Resolvable<SchedulerConfig>): Promise<SonamuScheduler>;
22
- //# sourceMappingURL=scheduler.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"scheduler.d.ts","sourceRoot":"","sources":["../src/scheduler.ts"],"names":[],"mappings":"AACA,OAAa,EAAE,KAAK,IAAI,EAAE,MAAM,MAAM,CAAC;AAEvC,OAAO,EAAE,KAAK,aAAa,EAA0B,MAAM,MAAM,CAAC;AAGlE,OAAO,EAEL,KAAK,SAAS,EACd,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,UAAU,EACf,KAAK,WAAW,EAEhB,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACvB,MAAM,SAAS,CAAC;AAGjB,qBAAa,eAAe;;IAQ1B,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;gBAG3B,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,aAAa,CAAC,iBAAiB,GAAG;QAAE,IAAI,EAAE,aAAa,CAAA;KAAE,CAAC,EAClE,IAAI,EAAE,aAAa,EACnB,KAAK,CAAC,EAAE,WAAW;IAWf,CAAC,MAAM,CAAC,YAAY,CAAC;IAI3B,QAAQ,CAAC,GAAG,MAAM,EAAE,CAAC,IAAI,CAAC,iBAAiB,EAAE,OAAO,CAAC,GAAG;QAAE,KAAK,CAAC,EAAE,WAAW,CAAA;KAAE,CAAC,EAAE;IAclF,OAAO,CAAC,GAAG,KAAK,EAAE,CAAC,gBAAgB,GAAG,eAAe,CAAC,EAAE;IA2BxD,KAAK;IASL,IAAI;IASE,OAAO;IAcb,EAAE,CAAC,IAAI,EAAE,SAAS,GAAG,GAAG,EAAE,EAAE,EAAE,eAAe;IAM7C,GAAG,CAAC,IAAI,EAAE,SAAS,GAAG,GAAG,EAAE,EAAE,EAAE,eAAe;CAW/C;AAED,wBAAsB,eAAe,CACnC,KAAK,EAAE,UAAU,CAAC,eAAe,CAAC,GACjC,OAAO,CAAC,eAAe,CAAC,CAY1B"}