koatty_schedule 1.6.0 → 2.0.0

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/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  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
4
 
5
+ ## [2.0.0](https://github.com/thinkkoa/koatty_schedule/compare/v1.6.0...v2.0.0) (2024-01-17)
6
+
7
+
8
+ ### Refactor
9
+
10
+ * redlock ([beb7cd9](https://github.com/thinkkoa/koatty_schedule/commit/beb7cd90878319cb1c480f4ad11b2632c184872b))
11
+ * redlock ([ea29337](https://github.com/thinkkoa/koatty_schedule/commit/ea29337052aee081322918914876a95923d314ae))
12
+
5
13
  ## [1.6.0](https://github.com/thinkkoa/koatty_schedule/compare/v1.5.11...v1.6.0) (2023-12-20)
6
14
 
7
15
  ### [1.5.11](https://github.com/thinkkoa/koatty_schedule/compare/v1.5.10...v1.5.11) (2023-07-28)
package/dist/index.d.ts CHANGED
@@ -1,47 +1,41 @@
1
1
  /*!
2
2
  * @Author: richen
3
- * @Date: 2023-12-20 19:48:19
3
+ * @Date: 2024-01-17 13:04:42
4
4
  * @License: BSD (3-Clause)
5
5
  * @Copyright (c) - <richenlin(at)gmail.com>
6
6
  * @HomePage: https://koatty.org/
7
7
  */
8
- import { Application } from 'koatty_container';
9
-
10
- /**
11
- * get instances of cacheStore
12
- *
13
- * @export
14
- * @param {Application} app
15
- * @returns {*} {CacheStore}
16
- */
17
- export declare function GetScheduleLocker(app: Application): Promise<LockerInterface>;
18
-
19
- /**
20
- * Inject schedule job
21
- *
22
- * @export
23
- * @param {*} target
24
- */
25
- export declare function injectSchedule(target: any): void;
8
+ import { RedisOptions } from 'ioredis';
26
9
 
27
10
  /**
28
11
  * Redis-based distributed locks. Redis server config from db.ts.
29
12
  *
30
13
  * @export
31
14
  * @param {string} [name] The locker name. If name is duplicated, lock sharing contention will result.
32
- * @param {number} [lockTimeOut] Automatic release of lock within a limited maximum time.
33
- * @param {number} [waitLockInterval] Try to acquire lock every interval time(millisecond).
34
- * @param {number} [waitLockTimeOut] When using more than TimeOut(millisecond) still fails to get the lock and return failure.
15
+ * @param {number} [lockTimeOut] Automatic release of lock within a limited maximum time. default 10000
16
+ * @param {number} [waitLockRetry] Try to acquire lock max time. default 3
35
17
  *
36
18
  * @returns {MethodDecorator}
37
19
  */
38
- export declare const Lock: typeof SchedulerLock;
20
+ export declare function RedLock(name?: string, options?: RedLockOptions): MethodDecorator;
39
21
 
40
- declare interface LockerInterface {
41
- getClient?: () => Promise<any>;
42
- lock?: (key: string, expire?: number) => Promise<boolean>;
43
- waitLock?: (key: string, expire: number, interval?: number, waitTime?: number) => Promise<boolean>;
44
- unLock?: (key: string) => Promise<boolean>;
22
+ /**
23
+ * @description: RedLockOptions
24
+ * @return {*}
25
+ */
26
+ declare interface RedLockOptions {
27
+ /**
28
+ * lock a resource times
29
+ */
30
+ lockTimeOut?: number;
31
+ /**
32
+ * The max number of times Redlock will attempt to lock a resource
33
+ */
34
+ retryCount?: number;
35
+ /**
36
+ * redis config
37
+ */
38
+ RedisOptions: RedisOptions;
45
39
  }
46
40
 
47
41
  /**
@@ -49,28 +43,16 @@ declare interface LockerInterface {
49
43
  *
50
44
  * @export
51
45
  * @param {string} cron
46
+ * @param {string} timezone
52
47
  * * Seconds: 0-59
53
48
  * * Minutes: 0-59
54
49
  * * Hours: 0-23
55
50
  * * Day of Month: 1-31
56
- * * Months: 0-11 (Jan-Dec)
57
- * * Day of Week: 0-6 (Sun-Sat)
58
- *
59
- * @returns {MethodDecorator}
60
- */
61
- export declare function Scheduled(cron: string): MethodDecorator;
62
-
63
- /**
64
- * Redis-based distributed locks. Redis server config from db.ts.
65
- *
66
- * @export
67
- * @param {string} [name] The locker name. If name is duplicated, lock sharing contention will result.
68
- * @param {number} [lockTimeOut] Automatic release of lock within a limited maximum time.
69
- * @param {number} [waitLockInterval] Try to acquire lock every interval time(millisecond).
70
- * @param {number} [waitLockTimeOut] When using more than TimeOut(millisecond) still fails to get the lock and return failure.
51
+ * * Months: 1-12 (Jan-Dec)
52
+ * * Day of Week: 1-7 (Sun-Sat)
71
53
  *
72
54
  * @returns {MethodDecorator}
73
55
  */
74
- export declare function SchedulerLock(name?: string, lockTimeOut?: number, waitLockInterval?: number, waitLockTimeOut?: number): MethodDecorator;
56
+ export declare function Scheduled(cron: string, timezone?: string): MethodDecorator;
75
57
 
76
58
  export { }