koatty_schedule 1.6.0 → 2.0.1

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,16 @@
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.1](https://github.com/thinkkoa/koatty_schedule/compare/v2.0.0...v2.0.1) (2024-01-17)
6
+
7
+ ## [2.0.0](https://github.com/thinkkoa/koatty_schedule/compare/v1.6.0...v2.0.0) (2024-01-17)
8
+
9
+
10
+ ### Refactor
11
+
12
+ * redlock ([beb7cd9](https://github.com/thinkkoa/koatty_schedule/commit/beb7cd90878319cb1c480f4ad11b2632c184872b))
13
+ * redlock ([ea29337](https://github.com/thinkkoa/koatty_schedule/commit/ea29337052aee081322918914876a95923d314ae))
14
+
5
15
  ## [1.6.0](https://github.com/thinkkoa/koatty_schedule/compare/v1.5.11...v1.6.0) (2023-12-20)
6
16
 
7
17
  ### [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,45 @@
1
1
  /*!
2
2
  * @Author: richen
3
- * @Date: 2023-12-20 19:48:19
3
+ * @Date: 2024-01-17 13:24:21
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 {RedLockOptions} [options]
16
+ *
17
+ * lockTimeOut ?: number; lock a resource times
18
+ *
19
+ * retryCount ?: number; The max number of times Redlock will attempt to lock a resource
35
20
  *
21
+ * RedisOptions: RedisOptions; redis config
36
22
  * @returns {MethodDecorator}
37
23
  */
38
- export declare const Lock: typeof SchedulerLock;
24
+ export declare function RedLock(name?: string, options?: RedLockOptions): MethodDecorator;
39
25
 
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>;
26
+ /**
27
+ * @description: RedLockOptions
28
+ * @return {*}
29
+ */
30
+ declare interface RedLockOptions {
31
+ /**
32
+ * lock a resource times
33
+ */
34
+ lockTimeOut?: number;
35
+ /**
36
+ * The max number of times Redlock will attempt to lock a resource
37
+ */
38
+ retryCount?: number;
39
+ /**
40
+ * redis config
41
+ */
42
+ RedisOptions: RedisOptions;
45
43
  }
46
44
 
47
45
  /**
@@ -49,28 +47,16 @@ declare interface LockerInterface {
49
47
  *
50
48
  * @export
51
49
  * @param {string} cron
50
+ * @param {string} timezone
52
51
  * * Seconds: 0-59
53
52
  * * Minutes: 0-59
54
53
  * * Hours: 0-23
55
54
  * * 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.
55
+ * * Months: 1-12 (Jan-Dec)
56
+ * * Day of Week: 1-7 (Sun-Sat)
71
57
  *
72
58
  * @returns {MethodDecorator}
73
59
  */
74
- export declare function SchedulerLock(name?: string, lockTimeOut?: number, waitLockInterval?: number, waitLockTimeOut?: number): MethodDecorator;
60
+ export declare function Scheduled(cron: string, timezone?: string): MethodDecorator;
75
61
 
76
62
  export { }