koatty_schedule 3.3.2 → 3.3.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.
@@ -0,0 +1,75 @@
1
+
2
+ > koatty_schedule@3.3.4 build /Users/richen/Workspace/nodejs/koatty-monorepo/packages/koatty-schedule
3
+ > npm run build:js && npm run build:dts && npm run build:doc && npm run build:cp
4
+
5
+
6
+ > koatty_schedule@3.3.4 build:js
7
+ > npx rollup --bundleConfigAsCjs -c .rollup.config.js
8
+
9
+ 
10
+ ./src/index.ts → ./dist/index.js, ./dist/index.mjs...
11
+ created ./dist/index.js, ./dist/index.mjs in 1.1s
12
+
13
+ > koatty_schedule@3.3.4 build:dts
14
+ > npx tsc && npx api-extractor run --local --verbose
15
+
16
+
17
+ api-extractor 7.55.2  - https://api-extractor.com/
18
+ 
19
+ Using configuration from ./api-extractor.json
20
+ Analysis will use the bundled TypeScript version 5.8.2
21
+ *** The target project appears to use TypeScript 5.9.3 which is newer than the bundled compiler engine; consider upgrading API Extractor.
22
+ Writing: /Users/richen/Workspace/nodejs/koatty-monorepo/packages/koatty-schedule/temp/koatty_schedule.api.json
23
+ Writing package typings: /Users/richen/Workspace/nodejs/koatty-monorepo/packages/koatty-schedule/dist/index.d.ts
24
+ Warning: src/decorator/redlock.ts:18:4 - (tsdoc-undefined-tag) The TSDoc tag "@export" is not defined in this configuration
25
+ Warning: src/decorator/redlock.ts:19:20 - (tsdoc-param-tag-with-invalid-optional-name) The @param should not include a JSDoc-style optional name; it must not be enclosed in '[ ]' brackets.
26
+ Warning: src/decorator/redlock.ts:19:11 - (tsdoc-param-tag-with-invalid-type) The @param block should not include a JSDoc-style '{type}'
27
+ Warning: src/decorator/redlock.ts:22:34 - (tsdoc-param-tag-with-invalid-optional-name) The @param should not include a JSDoc-style optional name; it must not be enclosed in '[ ]' brackets.
28
+ Warning: src/decorator/redlock.ts:22:11 - (tsdoc-param-tag-with-invalid-type) The @param block should not include a JSDoc-style '{type}'
29
+ Warning: src/decorator/redlock.ts:24:29 - (tsdoc-escape-right-brace) The "}" character should be escaped using a backslash to avoid confusion with a TSDoc inline tag
30
+ Warning: src/decorator/redlock.ts:24:13 - (tsdoc-malformed-inline-tag) Expecting a TSDoc tag starting with "{@"
31
+ Warning: src/decorator/redlock.ts:25:18 - (tsdoc-escape-right-brace) The "}" character should be escaped using a backslash to avoid confusion with a TSDoc inline tag
32
+ Warning: src/decorator/redlock.ts:25:12 - (tsdoc-malformed-inline-tag) Expecting a TSDoc tag starting with "{@"
33
+ Warning: src/decorator/redlock.ts:42:1 - (ae-forgotten-export) The symbol "RedLockMethodOptions" needs to be exported by the entry point index.d.ts
34
+ Warning: src/decorator/scheduled.ts:18:4 - (tsdoc-undefined-tag) The TSDoc tag "@export" is not defined in this configuration
35
+ Warning: src/decorator/scheduled.ts:19:11 - (tsdoc-param-tag-with-invalid-type) The @param block should not include a JSDoc-style '{type}'
36
+ Warning: src/decorator/scheduled.ts:20:20 - (tsdoc-param-tag-with-invalid-optional-name) The @param should not include a JSDoc-style optional name; it must not be enclosed in '[ ]' brackets.
37
+ Warning: src/decorator/scheduled.ts:20:11 - (tsdoc-param-tag-with-invalid-type) The @param block should not include a JSDoc-style '{type}'
38
+ Warning: src/decorator/scheduled.ts:30:29 - (tsdoc-escape-right-brace) The "}" character should be escaped using a backslash to avoid confusion with a TSDoc inline tag
39
+ Warning: src/decorator/scheduled.ts:30:13 - (tsdoc-malformed-inline-tag) Expecting a TSDoc tag starting with "{@"
40
+ Warning: src/decorator/scheduled.ts:31:18 - (tsdoc-escape-right-brace) The "}" character should be escaped using a backslash to avoid confusion with a TSDoc inline tag
41
+ Warning: src/decorator/scheduled.ts:31:12 - (tsdoc-malformed-inline-tag) Expecting a TSDoc tag starting with "{@"
42
+ Warning: src/index.ts:62:1 - (ae-forgotten-export) The symbol "ScheduledOptions" needs to be exported by the entry point index.d.ts
43
+ Warning: src/locker/interface.ts:50:1 - (ae-forgotten-export) The symbol "BaseRedisConfig" needs to be exported by the entry point index.d.ts
44
+ Warning: src/locker/redlock.ts:79:6 - (tsdoc-undefined-tag) The TSDoc tag "@private" is not defined in this configuration
45
+ Warning: src/locker/redlock.ts:96:6 - (tsdoc-undefined-tag) The TSDoc tag "@static" is not defined in this configuration
46
+ Warning: src/locker/redlock.ts:132:6 - (tsdoc-undefined-tag) The TSDoc tag "@static" is not defined in this configuration
47
+ Warning: src/locker/redlock.ts:146:6 - (tsdoc-undefined-tag) The TSDoc tag "@private" is not defined in this configuration
48
+ Warning: src/locker/redlock.ts:177:6 - (tsdoc-undefined-tag) The TSDoc tag "@private" is not defined in this configuration
49
+
50
+ API Extractor completed successfully
51
+
52
+ > koatty_schedule@3.3.4 build:doc
53
+ > npx api-documenter markdown --input temp --output docs/api
54
+
55
+
56
+ api-documenter 7.28.2  - https://api-extractor.com/
57
+ 
58
+ Reading koatty_schedule.api.json
59
+
60
+ Deleting old output from docs/api
61
+ Writing koatty_schedule package
62
+ Unsupported block tag: @export
63
+ Unsupported block tag: @static
64
+ Unsupported block tag: @private
65
+ Unsupported block tag: @static
66
+ Unsupported block tag: @static
67
+ Unsupported block tag: @private
68
+ Unsupported block tag: @static
69
+ Unsupported block tag: @export
70
+ Unsupported block tag: @export
71
+ Unsupported block tag: @export
72
+
73
+ > koatty_schedule@3.3.4 build:cp
74
+ > node scripts/postBuild && npx copyfiles package.json LICENSE README.md dist/
75
+
package/CHANGELOG.md CHANGED
@@ -1,32 +1,42 @@
1
1
  # Changelog
2
2
 
3
+ ## 3.3.4
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+ - koatty_lib@1.4.2
9
+ - koatty_container@1.17.1
10
+ - koatty_core@2.0.11
11
+ - koatty_logger@2.3.1
12
+ - koatty_store@1.9.1
13
+
3
14
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
15
 
16
+ ### [3.3.3](https://github.com/thinkkoa/koatty_schedule/compare/v3.3.2...v3.3.3) (2025-10-31)
17
+
5
18
  ### [3.3.2](https://github.com/thinkkoa/koatty_schedule/compare/v3.3.1...v3.3.2) (2025-06-22)
6
19
 
7
20
  ### [3.3.1](https://github.com/thinkkoa/koatty_schedule/compare/v3.3.0...v3.3.1) (2025-06-22)
8
21
 
9
-
10
22
  ### Bug Fixes
11
23
 
12
- * unify component type constant to 'COMPONENT' string literal in IOCContainer registration ([7098c7e](https://github.com/thinkkoa/koatty_schedule/commit/7098c7e2c326a6461b6b8b5c84d07a3ced75de5f))
24
+ - unify component type constant to 'COMPONENT' string literal in IOCContainer registration ([7098c7e](https://github.com/thinkkoa/koatty_schedule/commit/7098c7e2c326a6461b6b8b5c84d07a3ced75de5f))
13
25
 
14
26
  ## [3.3.0](https://github.com/thinkkoa/koatty_schedule/compare/v3.2.0...v3.3.0) (2025-06-22)
15
27
 
16
-
17
28
  ### Features
18
29
 
19
- * enhance distributed locking and scheduling system with global configuration management and improved validation ([79a10f5](https://github.com/thinkkoa/koatty_schedule/commit/79a10f5a1ac66958aa44d3ea9151a65826748724))
20
- * improve RedLock singleton management with thread-safe initialization and lock renewal enhancements ([ec426aa](https://github.com/thinkkoa/koatty_schedule/commit/ec426aae3cd0d824661b1b94ae8043bf66ace606))
21
- * introduce component-specific metadata keys for scheduled and redlock decorators ([173e79a](https://github.com/thinkkoa/koatty_schedule/commit/173e79ac916c13b20c93d2efac7e69009cc5cf32))
22
- * refactor RedLock configuration and remove deprecated ScheduleConfig ([7bd4667](https://github.com/thinkkoa/koatty_schedule/commit/7bd4667242c6fd07cfd58a4322d93f4c4548100a))
23
- * update decorator types to support symbol property keys and improve IOC container integration ([f7b6382](https://github.com/thinkkoa/koatty_schedule/commit/f7b6382e855914176c130b10a769b03cc74c0f23))
24
- * use dynamic componentType instead of hardcoded constants for IOCContainer registration ([42ca073](https://github.com/thinkkoa/koatty_schedule/commit/42ca07353a8082b1af9e49d43914497d41cddd27))
25
-
30
+ - enhance distributed locking and scheduling system with global configuration management and improved validation ([79a10f5](https://github.com/thinkkoa/koatty_schedule/commit/79a10f5a1ac66958aa44d3ea9151a65826748724))
31
+ - improve RedLock singleton management with thread-safe initialization and lock renewal enhancements ([ec426aa](https://github.com/thinkkoa/koatty_schedule/commit/ec426aae3cd0d824661b1b94ae8043bf66ace606))
32
+ - introduce component-specific metadata keys for scheduled and redlock decorators ([173e79a](https://github.com/thinkkoa/koatty_schedule/commit/173e79ac916c13b20c93d2efac7e69009cc5cf32))
33
+ - refactor RedLock configuration and remove deprecated ScheduleConfig ([7bd4667](https://github.com/thinkkoa/koatty_schedule/commit/7bd4667242c6fd07cfd58a4322d93f4c4548100a))
34
+ - update decorator types to support symbol property keys and improve IOC container integration ([f7b6382](https://github.com/thinkkoa/koatty_schedule/commit/f7b6382e855914176c130b10a769b03cc74c0f23))
35
+ - use dynamic componentType instead of hardcoded constants for IOCContainer registration ([42ca073](https://github.com/thinkkoa/koatty_schedule/commit/42ca07353a8082b1af9e49d43914497d41cddd27))
26
36
 
27
37
  ### Bug Fixes
28
38
 
29
- * 修复IOC容器元数据键格式不匹配问题 ([644714f](https://github.com/thinkkoa/koatty_schedule/commit/644714f20497196fb705e551880a9ef527257cb7))
39
+ - 修复 IOC 容器元数据键格式不匹配问题 ([644714f](https://github.com/thinkkoa/koatty_schedule/commit/644714f20497196fb705e551880a9ef527257cb7))
30
40
 
31
41
  ### [2.1.1](https://github.com/thinkkoa/koatty_schedule/compare/v2.1.0...v2.1.1) (2025-06-09)
32
42
 
@@ -34,60 +44,52 @@ All notable changes to this project will be documented in this file. See [standa
34
44
 
35
45
  ## [3.2.0](https://github.com/thinkkoa/koatty_schedule/compare/v3.1.0...v3.2.0) (2025-06-22)
36
46
 
37
-
38
47
  ### Features
39
48
 
40
- * introduce component-specific metadata keys for scheduled and redlock decorators ([803b350](https://github.com/thinkkoa/koatty_schedule/commit/803b3503489c02ab138b3f9f14cb520dd6c7fec4))
41
-
49
+ - introduce component-specific metadata keys for scheduled and redlock decorators ([803b350](https://github.com/thinkkoa/koatty_schedule/commit/803b3503489c02ab138b3f9f14cb520dd6c7fec4))
42
50
 
43
51
  ### Bug Fixes
44
52
 
45
- * 修复IOC容器元数据键格式不匹配问题 ([065d456](https://github.com/thinkkoa/koatty_schedule/commit/065d456fc65004e25eb19838da96bf0a52cb2af1))
53
+ - 修复 IOC 容器元数据键格式不匹配问题 ([065d456](https://github.com/thinkkoa/koatty_schedule/commit/065d456fc65004e25eb19838da96bf0a52cb2af1))
46
54
 
47
55
  ## [3.1.0](https://github.com/thinkkoa/koatty_schedule/compare/v3.0.0...v3.1.0) (2025-06-21)
48
56
 
49
-
50
57
  ### Features
51
58
 
52
- * update decorator types to support symbol property keys and improve IOC container integration ([a60ef3e](https://github.com/thinkkoa/koatty_schedule/commit/a60ef3e361b245f97ba0d6ee51d42efd437a1252))
59
+ - update decorator types to support symbol property keys and improve IOC container integration ([a60ef3e](https://github.com/thinkkoa/koatty_schedule/commit/a60ef3e361b245f97ba0d6ee51d42efd437a1252))
53
60
 
54
61
  ## [3.0.0](https://github.com/thinkkoa/koatty_schedule/compare/v2.1.0...v3.0.0) (2025-06-21)
55
62
 
56
-
57
63
  ### Features
58
64
 
59
- * enhance distributed locking and scheduling system with global configuration management and improved validation ([cf3924c](https://github.com/thinkkoa/koatty_schedule/commit/cf3924cf6bccf951f070c68e33483ae935828382))
60
- * improve RedLock singleton management with thread-safe initialization and lock renewal enhancements ([4e381cd](https://github.com/thinkkoa/koatty_schedule/commit/4e381cd8eec6aa366a6db813918f213f07b02921))
61
- * refactor RedLock configuration and remove deprecated ScheduleConfig ([bb10ac7](https://github.com/thinkkoa/koatty_schedule/commit/bb10ac7dab67d32ca75a43db92c587a662bc1b9f))
65
+ - enhance distributed locking and scheduling system with global configuration management and improved validation ([cf3924c](https://github.com/thinkkoa/koatty_schedule/commit/cf3924cf6bccf951f070c68e33483ae935828382))
66
+ - improve RedLock singleton management with thread-safe initialization and lock renewal enhancements ([4e381cd](https://github.com/thinkkoa/koatty_schedule/commit/4e381cd8eec6aa366a6db813918f213f07b02921))
67
+ - refactor RedLock configuration and remove deprecated ScheduleConfig ([bb10ac7](https://github.com/thinkkoa/koatty_schedule/commit/bb10ac7dab67d32ca75a43db92c587a662bc1b9f))
62
68
 
63
69
  ## [2.1.0](https://github.com/thinkkoa/koatty_schedule/compare/v2.0.1...v2.1.0) (2025-06-09)
64
70
 
65
-
66
71
  ### Features
67
72
 
68
- * add schedule and redlock decorators with config management ([c1b5359](https://github.com/thinkkoa/koatty_schedule/commit/c1b535940df2b8a3403bf024137519246945870e))
69
- * enhance ConfigManager with singleton pattern, environment config loading ([00db6eb](https://github.com/thinkkoa/koatty_schedule/commit/00db6eb97bdae226aaf433b23c770704b33d05e8))
70
- * introduce DecoratorType enum, refactor decorator management system, ([e58e718](https://github.com/thinkkoa/koatty_schedule/commit/e58e718975e663820778352bedb6421e6852ba9f))
71
-
73
+ - add schedule and redlock decorators with config management ([c1b5359](https://github.com/thinkkoa/koatty_schedule/commit/c1b535940df2b8a3403bf024137519246945870e))
74
+ - enhance ConfigManager with singleton pattern, environment config loading ([00db6eb](https://github.com/thinkkoa/koatty_schedule/commit/00db6eb97bdae226aaf433b23c770704b33d05e8))
75
+ - introduce DecoratorType enum, refactor decorator management system, ([e58e718](https://github.com/thinkkoa/koatty_schedule/commit/e58e718975e663820778352bedb6421e6852ba9f))
72
76
 
73
77
  ### Bug Fixes
74
78
 
75
- * simplify error handling in ConfigManager and RedLocker ([7be75fc](https://github.com/thinkkoa/koatty_schedule/commit/7be75fc7f4160094b57ca64905df4c81f77adb51))
76
-
79
+ - simplify error handling in ConfigManager and RedLocker ([7be75fc](https://github.com/thinkkoa/koatty_schedule/commit/7be75fc7f4160094b57ca64905df4c81f77adb51))
77
80
 
78
81
  ### Refactor
79
82
 
80
- * use MethodDecoratorManager ([ff077c7](https://github.com/thinkkoa/koatty_schedule/commit/ff077c7211bb6cf258c6885e1d7dcbdacde90ef1))
83
+ - use MethodDecoratorManager ([ff077c7](https://github.com/thinkkoa/koatty_schedule/commit/ff077c7211bb6cf258c6885e1d7dcbdacde90ef1))
81
84
 
82
85
  ### [2.0.1](https://github.com/thinkkoa/koatty_schedule/compare/v2.0.0...v2.0.1) (2024-01-17)
83
86
 
84
87
  ## [2.0.0](https://github.com/thinkkoa/koatty_schedule/compare/v1.6.0...v2.0.0) (2024-01-17)
85
88
 
86
-
87
89
  ### Refactor
88
90
 
89
- * redlock ([beb7cd9](https://github.com/thinkkoa/koatty_schedule/commit/beb7cd90878319cb1c480f4ad11b2632c184872b))
90
- * redlock ([ea29337](https://github.com/thinkkoa/koatty_schedule/commit/ea29337052aee081322918914876a95923d314ae))
91
+ - redlock ([beb7cd9](https://github.com/thinkkoa/koatty_schedule/commit/beb7cd90878319cb1c480f4ad11b2632c184872b))
92
+ - redlock ([ea29337](https://github.com/thinkkoa/koatty_schedule/commit/ea29337052aee081322918914876a95923d314ae))
91
93
 
92
94
  ## [1.6.0](https://github.com/thinkkoa/koatty_schedule/compare/v1.5.11...v1.6.0) (2023-12-20)
93
95
 
@@ -99,11 +101,10 @@ All notable changes to this project will be documented in this file. See [standa
99
101
 
100
102
  ### [1.5.7](https://github.com/thinkkoa/koatty_schedule/compare/v1.5.6...v1.5.7) (2022-09-05)
101
103
 
102
-
103
104
  ### Bug Fixes
104
105
 
105
- * update ([8eb40be](https://github.com/thinkkoa/koatty_schedule/commit/8eb40be4f0778d218a2a8b9a9370ffbe26c9e884))
106
- * upgrade deps ([51a68af](https://github.com/thinkkoa/koatty_schedule/commit/51a68af12437a08e3a5468b27b57ae597f66695d))
106
+ - update ([8eb40be](https://github.com/thinkkoa/koatty_schedule/commit/8eb40be4f0778d218a2a8b9a9370ffbe26c9e884))
107
+ - upgrade deps ([51a68af](https://github.com/thinkkoa/koatty_schedule/commit/51a68af12437a08e3a5468b27b57ae597f66695d))
107
108
 
108
109
  ### [1.5.6](https://github.com/thinkkoa/koatty_schedule/compare/v1.5.5...v1.5.6) (2022-05-27)
109
110
 
package/README.md CHANGED
@@ -11,12 +11,15 @@ Powerful scheduled tasks and distributed locking solution for Koatty framework.
11
11
  - 🕒 **Flexible Scheduling**: Support for cron expressions with timezone configuration
12
12
  - 🔐 **Distributed Locking**: RedLock-based distributed locks with auto-extension
13
13
  - 🏗️ **Plugin Architecture**: Native Koatty plugin integration
14
- - ⚡ **Performance Optimized**: Singleton pattern, caching, and batch processing
15
- - 🛡️ **Enhanced Safety**: Lock renewal logic with timeout protection
14
+ - ⚡ **Performance Optimized**: Singleton pattern, caching, and memory-leak-free design
15
+ - 🛡️ **Enhanced Safety**: Lock renewal logic with timeout protection and automatic cleanup
16
16
  - 🌍 **Timezone Smart**: Three-tier priority system for timezone configuration
17
17
  - 📊 **Health Monitoring**: Built-in health checks and detailed status reporting
18
18
  - 🔧 **Easy Configuration**: Method-level and global configuration options
19
19
  - 🚀 **Smart Initialization**: Unified initialization timing for optimal dependency resolution
20
+ - 🎯 **Advanced Validation**: Comprehensive cron expression validation with bilingual error messages
21
+ - 🔌 **Redis Multi-Mode**: Support for Standalone, Sentinel, and Cluster Redis deployments
22
+ - 🧩 **Extensible Architecture**: Abstract interfaces for easy customization and extension
20
23
 
21
24
  ## Installation
22
25
 
@@ -53,6 +56,8 @@ export class Scheduled implements IPlugin {
53
56
  Update `src/config/plugin.ts`:
54
57
 
55
58
  ```typescript
59
+ import { RedisMode } from "koatty_schedule";
60
+
56
61
  export default {
57
62
  list: ["Scheduled"], // Plugin loading order
58
63
  config: {
@@ -62,6 +67,7 @@ export default {
62
67
  maxRetries: 3,
63
68
  retryDelayMs: 200,
64
69
  redisConfig: {
70
+ mode: RedisMode.STANDALONE, // or SENTINEL, CLUSTER
65
71
  host: "127.0.0.1",
66
72
  port: 6379,
67
73
  db: 0,
@@ -119,11 +125,96 @@ export class CriticalTaskService {
119
125
 
120
126
  ## Advanced Configuration
121
127
 
128
+ ### Redis Deployment Modes
129
+
130
+ koatty_schedule supports three Redis deployment modes:
131
+
132
+ #### Standalone Mode (Default)
133
+
134
+ ```typescript
135
+ import { RedisMode } from "koatty_schedule";
136
+
137
+ export default {
138
+ list: ["Scheduled"],
139
+ config: {
140
+ Scheduled: {
141
+ redisConfig: {
142
+ mode: RedisMode.STANDALONE, // or omit for default
143
+ host: "127.0.0.1",
144
+ port: 6379,
145
+ password: "your-password",
146
+ db: 0,
147
+ keyPrefix: "koatty:schedule:"
148
+ }
149
+ }
150
+ }
151
+ };
152
+ ```
153
+
154
+ #### Sentinel Mode (High Availability)
155
+
156
+ ```typescript
157
+ import { RedisMode } from "koatty_schedule";
158
+
159
+ export default {
160
+ list: ["Scheduled"],
161
+ config: {
162
+ Scheduled: {
163
+ redisConfig: {
164
+ mode: RedisMode.SENTINEL,
165
+ sentinels: [
166
+ { host: "192.168.1.10", port: 26379 },
167
+ { host: "192.168.1.11", port: 26379 },
168
+ { host: "192.168.1.12", port: 26379 }
169
+ ],
170
+ name: "mymaster", // Sentinel master name
171
+ password: "your-password",
172
+ sentinelPassword: "sentinel-password", // Optional
173
+ db: 0,
174
+ keyPrefix: "koatty:schedule:"
175
+ }
176
+ }
177
+ }
178
+ };
179
+ ```
180
+
181
+ #### Cluster Mode (Horizontal Scaling)
182
+
183
+ ```typescript
184
+ import { RedisMode } from "koatty_schedule";
185
+
186
+ export default {
187
+ list: ["Scheduled"],
188
+ config: {
189
+ Scheduled: {
190
+ redisConfig: {
191
+ mode: RedisMode.CLUSTER,
192
+ nodes: [
193
+ { host: "192.168.1.10", port: 7000 },
194
+ { host: "192.168.1.11", port: 7001 },
195
+ { host: "192.168.1.12", port: 7002 },
196
+ { host: "192.168.1.13", port: 7003 },
197
+ { host: "192.168.1.14", port: 7004 },
198
+ { host: "192.168.1.15", port: 7005 }
199
+ ],
200
+ redisOptions: {
201
+ password: "your-password",
202
+ db: 0
203
+ },
204
+ keyPrefix: "koatty:schedule:"
205
+ }
206
+ }
207
+ }
208
+ };
209
+ ```
210
+
122
211
  ### Global Plugin Configuration
123
212
 
124
213
  Configure global settings in `src/config/plugin.ts`:
125
214
 
126
215
  ```typescript
216
+ import { RedisMode } from "koatty_schedule";
217
+
127
218
  export default {
128
219
  list: ["Scheduled"],
129
220
  config: {
@@ -139,6 +230,7 @@ export default {
139
230
 
140
231
  // Redis configuration for distributed locks
141
232
  redisConfig: {
233
+ mode: RedisMode.STANDALONE,
142
234
  host: "redis.example.com",
143
235
  port: 6379,
144
236
  password: "your-password",
@@ -324,6 +416,10 @@ export class LongRunningTaskService {
324
416
 
325
417
  ## Cron Expression Examples
326
418
 
419
+ koatty_schedule supports both 5-part and 6-part (with seconds) cron expressions with comprehensive validation:
420
+
421
+ ### Basic Examples
422
+
327
423
  ```typescript
328
424
  export class CronExamplesService {
329
425
 
@@ -347,6 +443,90 @@ export class CronExamplesService {
347
443
  }
348
444
  ```
349
445
 
446
+ ### Advanced Examples (NEW in v3.4.0)
447
+
448
+ ```typescript
449
+ export class AdvancedCronService {
450
+
451
+ // Step values - Every 2 hours during business hours
452
+ @Scheduled('0 0 9-17/2 * * 1-5')
453
+ async businessHoursTask() { }
454
+
455
+ // List values - Run at 9 AM, 12 PM, and 6 PM
456
+ @Scheduled('0 0 9,12,18 * * *')
457
+ async specificHoursTask() { }
458
+
459
+ // Month names - Run on first day of Q1 months
460
+ @Scheduled('0 0 0 1 JAN,FEB,MAR *')
461
+ async quarterlyTask() { }
462
+
463
+ // Weekday names - Weekend morning task
464
+ @Scheduled('0 0 10 * * SAT,SUN')
465
+ async weekendTask() { }
466
+
467
+ // Complex expression - Every 15 minutes during working hours on weekdays
468
+ @Scheduled('0 */15 9-17 * * MON-FRI')
469
+ async frequentBusinessTask() { }
470
+
471
+ // Range with step - Every 3 days
472
+ @Scheduled('0 0 0 */3 * *')
473
+ async everyThreeDaysTask() { }
474
+ }
475
+ ```
476
+
477
+ ### Cron Expression Format
478
+
479
+ **6-part format (with seconds):**
480
+ ```
481
+ ┌────────────── second (0-59)
482
+ │ ┌──────────── minute (0-59)
483
+ │ │ ┌────────── hour (0-23)
484
+ │ │ │ ┌──────── day of month (1-31)
485
+ │ │ │ │ ┌────── month (1-12 or JAN-DEC)
486
+ │ │ │ │ │ ┌──── day of week (0-7 or SUN-SAT, 0 and 7 are Sunday)
487
+ │ │ │ │ │ │
488
+ * * * * * *
489
+ ```
490
+
491
+ **5-part format (without seconds):**
492
+ ```
493
+ ┌──────────── minute (0-59)
494
+ │ ┌────────── hour (0-23)
495
+ │ │ ┌──────── day of month (1-31)
496
+ │ │ │ ┌────── month (1-12 or JAN-DEC)
497
+ │ │ │ │ ┌──── day of week (0-7 or SUN-SAT)
498
+ │ │ │ │ │
499
+ * * * * *
500
+ ```
501
+
502
+ ### Special Characters
503
+
504
+ - `*` - Any value
505
+ - `,` - Value list separator (e.g., `1,3,5`)
506
+ - `-` - Range of values (e.g., `1-5`)
507
+ - `/` - Step values (e.g., `*/15` or `0-30/5`)
508
+
509
+ ### Validation Features (NEW)
510
+
511
+ The enhanced validator will catch common errors:
512
+
513
+ ```typescript
514
+ // ❌ Invalid - seconds out of range
515
+ @Scheduled('60 0 0 * * *') // Error: 秒字段的值无效: 60,必须在 0-59 之间
516
+
517
+ // ❌ Invalid - hours out of range
518
+ @Scheduled('0 0 25 * * *') // Error: 小时字段的值无效: 25,必须在 0-23 之间
519
+
520
+ // ❌ Invalid - invalid step value
521
+ @Scheduled('0 */0 * * * *') // Error: 分钟字段的步长值无效: 0
522
+
523
+ // ❌ Invalid - range start > end
524
+ @Scheduled('0 0 17-9 * * *') // Error: 小时字段的范围无效: 17-9
525
+
526
+ // ✅ Valid - all checks passed
527
+ @Scheduled('0 */15 9-17 * * 1-5') // Every 15 minutes, 9-5, weekdays
528
+ ```
529
+
350
530
  ## Troubleshooting
351
531
 
352
532
  ### Common Issues
@@ -391,32 +571,92 @@ DEBUG=koatty_schedule* npm start
391
571
  ### Decorators
392
572
 
393
573
  #### `@Scheduled(cron: string, timezone?: string)`
394
- - `cron`: Cron expression (6-part format with seconds)
574
+ - `cron`: Cron expression (5 or 6-part format, with comprehensive validation)
395
575
  - `timezone`: Optional timezone override (defaults to 'Asia/Beijing')
396
576
  - **Processing**: Records metadata in IOC container, CronJob created at `appReady`
577
+ - **Validation**: Full validation of all cron fields with bilingual error messages
397
578
 
398
579
  #### `@RedLock(lockName?: string, options?: RedLockMethodOptions)`
399
580
  - `lockName`: Unique lock identifier (auto-generated if not provided)
400
581
  - `options`: Method-level lock configuration
582
+ - **Features**: Automatic lock renewal (up to 3 times), memory-leak-free implementation
401
583
 
402
584
  ### Configuration Types
403
585
 
404
586
  ```typescript
587
+ // Scheduled options with Redis mode support
405
588
  interface ScheduledOptions {
406
589
  timezone?: string;
407
590
  lockTimeOut?: number;
408
591
  maxRetries?: number;
409
592
  retryDelayMs?: number;
410
593
  clockDriftFactor?: number;
411
- redisConfig?: RedisConfig;
594
+ redisConfig?: RedisConfig; // Supports Standalone, Sentinel, Cluster
412
595
  }
413
596
 
597
+ // RedLock method-level options
414
598
  interface RedLockMethodOptions {
415
599
  lockTimeOut?: number;
416
600
  maxRetries?: number;
417
601
  retryDelayMs?: number;
418
602
  clockDriftFactor?: number;
419
603
  }
604
+
605
+ // Redis configuration (NEW in v3.4.0)
606
+ enum RedisMode {
607
+ STANDALONE = 'standalone',
608
+ SENTINEL = 'sentinel',
609
+ CLUSTER = 'cluster'
610
+ }
611
+
612
+ interface RedisStandaloneConfig {
613
+ mode?: RedisMode.STANDALONE;
614
+ host: string;
615
+ port: number;
616
+ password?: string;
617
+ db?: number;
618
+ keyPrefix?: string;
619
+ }
620
+
621
+ interface RedisSentinelConfig {
622
+ mode: RedisMode.SENTINEL;
623
+ sentinels: Array<{ host: string; port: number }>;
624
+ name: string; // Master name
625
+ password?: string;
626
+ sentinelPassword?: string;
627
+ db?: number;
628
+ keyPrefix?: string;
629
+ }
630
+
631
+ interface RedisClusterConfig {
632
+ mode: RedisMode.CLUSTER;
633
+ nodes: Array<{ host: string; port: number }>;
634
+ redisOptions?: {
635
+ password?: string;
636
+ db?: number;
637
+ };
638
+ keyPrefix?: string;
639
+ }
640
+ ```
641
+
642
+ ### Exported Interfaces (NEW in v3.4.0)
643
+
644
+ For advanced customization and extension:
645
+
646
+ ```typescript
647
+ import {
648
+ IDistributedLock, // Abstract distributed lock interface
649
+ IRedisClient, // Abstract Redis client interface
650
+ RedisFactory, // Redis client factory
651
+ RedisClientAdapter, // Redis client adapter
652
+ RedLocker // RedLock implementation
653
+ } from "koatty_schedule";
654
+
655
+ // Example: Custom health check
656
+ const redLocker = RedLocker.getInstance();
657
+ const health = await redLocker.healthCheck();
658
+ console.log(health.status); // 'healthy' | 'unhealthy'
659
+ console.log(health.details); // Detailed status information
420
660
  ```
421
661
 
422
662
  ## Version Compatibility
@@ -424,6 +664,59 @@ interface RedLockMethodOptions {
424
664
  - **Koatty**: >= 2.0.0
425
665
  - **Node.js**: >= 14.0.0
426
666
  - **Redis**: >= 3.0.0
667
+ - **Redis Sentinel**: >= 3.0.0 (for high availability)
668
+ - **Redis Cluster**: >= 3.0.0 (for horizontal scaling)
669
+
670
+ ## What's New in v3.4.0 🎉
671
+
672
+ ### 🐛 Bug Fixes
673
+
674
+ - **Fixed memory leak** in `timeoutPromise` - timers are now properly cleaned up
675
+ - **Improved initialization cleanup** - prevents state inconsistency on retry
676
+
677
+ ### ✨ New Features
678
+
679
+ - **Redis Multi-Mode Support**: Standalone, Sentinel, and Cluster modes
680
+ - **Enhanced Cron Validation**: Complete validation of all fields with bilingual error messages
681
+ - **Abstract Interfaces**: `IDistributedLock` and `IRedisClient` for extensibility
682
+ - **Redis Factory**: `RedisFactory` for flexible Redis client creation
683
+
684
+ ### 🚀 Improvements
685
+
686
+ - Memory-leak-free design for long-running applications
687
+ - Better error messages with Chinese and English support
688
+ - Comprehensive cron expression validation (steps, ranges, lists, month/weekday names)
689
+ - Health check now reports Redis mode information
690
+
691
+ ### 📖 Documentation
692
+
693
+ - Added `UPGRADE_GUIDE.md` with migration instructions
694
+ - Added `IMPROVEMENTS_SUMMARY.md` with technical details
695
+ - Enhanced README with Redis multi-mode examples
696
+
697
+ ## Migration from v3.3.x
698
+
699
+ Most code works without changes. To use new features:
700
+
701
+ ```typescript
702
+ // Optional: Explicitly set Redis mode (defaults to STANDALONE)
703
+ import { RedisMode } from "koatty_schedule";
704
+
705
+ redisConfig: {
706
+ mode: RedisMode.STANDALONE, // or SENTINEL, CLUSTER
707
+ // ... rest of config
708
+ }
709
+ ```
710
+
711
+ See [UPGRADE_GUIDE.md](UPGRADE_GUIDE.md) for details.
712
+
713
+ ## Performance & Stability
714
+
715
+ - ✅ **Memory Stable**: No leaks in long-running applications
716
+ - ✅ **Production Ready**: Used in production environments
717
+ - ✅ **Well Tested**: Comprehensive test coverage
718
+ - ✅ **High Availability**: Sentinel mode support
719
+ - ✅ **Scalable**: Cluster mode for horizontal scaling
427
720
 
428
721
  ## License
429
722
 
@@ -437,4 +730,10 @@ We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) f
437
730
 
438
731
  - 📚 [Documentation](https://koatty.js.org/)
439
732
  - 🐛 [Issues](https://github.com/koattyjs/koatty_schedule/issues)
440
- - 💬 [Discussions](https://github.com/koattyjs/koatty_schedule/discussions)
733
+ - 💬 [Discussions](https://github.com/koattyjs/koatty_schedule/discussions)
734
+ - 📖 [Upgrade Guide](UPGRADE_GUIDE.md)
735
+ - 📝 [Changelog](CHANGELOG.md)
736
+
737
+ ---
738
+
739
+ **Maintained with ❤️ by the Koatty Team**