koatty_schedule 1.5.5 → 1.5.6

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,63 @@
1
+ /*
2
+ * @Description:
3
+ * @Usage:
4
+ * @Author: richen
5
+ * @Date: 2021-12-17 10:20:44
6
+ * @LastEditTime: 2021-12-18 11:58:46
7
+ */
8
+ import json from "@rollup/plugin-json";
9
+ import typescript from 'rollup-plugin-typescript2';
10
+ // import babel from '@rollup/plugin-babel';
11
+
12
+ export default [
13
+ {
14
+ input: './src/index.ts',
15
+ output: [{
16
+ format: 'cjs',
17
+ file: './dist/index.js',
18
+ banner: require('./scripts/copyright')
19
+ }],
20
+ plugins: [
21
+ // babel({
22
+ // babelHelpers: "runtime",
23
+ // configFile: './babel.config.js',
24
+ // exclude: 'node_modules/**',
25
+ // }),
26
+ json(),
27
+ typescript({
28
+ tsconfigOverride: {
29
+ compilerOptions: {
30
+ declaration: false,
31
+ declarationMap: false,
32
+ module: "ESNext"
33
+ }
34
+ }
35
+ })
36
+ ]
37
+ },
38
+ {
39
+ input: './src/index.ts',
40
+ output: [{
41
+ format: 'es',
42
+ file: './dist/index.mjs',
43
+ banner: require('./scripts/copyright')
44
+ }],
45
+ plugins: [
46
+ // babel({
47
+ // babelHelpers: "runtime",
48
+ // configFile: './babel.config.js',
49
+ // exclude: 'node_modules/**',
50
+ // }),
51
+ json(),
52
+ typescript({
53
+ tsconfigOverride: {
54
+ compilerOptions: {
55
+ declaration: false,
56
+ declarationMap: false,
57
+ module: "ESNext"
58
+ }
59
+ }
60
+ })
61
+ ]
62
+ }
63
+ ]
package/CHANGELOG.md CHANGED
@@ -2,6 +2,8 @@
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
+ ### [1.5.6](https://github.com/thinkkoa/koatty_schedule/compare/v1.5.5...v1.5.6) (2022-05-27)
6
+
5
7
  ### [1.5.5](https://github.com/thinkkoa/koatty_schedule/compare/v1.5.4...v1.5.5) (2022-03-02)
6
8
 
7
9
  ### [1.5.4](https://github.com/thinkkoa/koatty_schedule/compare/v1.5.2...v1.5.4) (2021-12-09)
package/dist/LICENSE ADDED
@@ -0,0 +1,29 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2020, Koatty
4
+ All rights reserved.
5
+
6
+ Redistribution and use in source and binary forms, with or without
7
+ modification, are permitted provided that the following conditions are met:
8
+
9
+ 1. Redistributions of source code must retain the above copyright notice, this
10
+ list of conditions and the following disclaimer.
11
+
12
+ 2. Redistributions in binary form must reproduce the above copyright notice,
13
+ this list of conditions and the following disclaimer in the documentation
14
+ and/or other materials provided with the distribution.
15
+
16
+ 3. Neither the name of the copyright holder nor the names of its
17
+ contributors may be used to endorse or promote products derived from
18
+ this software without specific prior written permission.
19
+
20
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package/dist/README.md ADDED
@@ -0,0 +1,48 @@
1
+ # koatty_schedule
2
+ Schedule for koatty.
3
+
4
+ Koatty框架的 Scheduled, SchedulerLock, Lock 支持库
5
+
6
+
7
+ # Usage
8
+
9
+ db.ts in koatty project:
10
+
11
+ ```js
12
+ export default {
13
+ ...
14
+
15
+ "CacheStore": {
16
+ type: "memory", // redis or memory, memory is default
17
+ // key_prefix: "koatty",
18
+ // host: '127.0.0.1',
19
+ // port: 6379,
20
+ // name: "",
21
+ // username: "",
22
+ // password: "",
23
+ // db: 0,
24
+ // timeout: 30,
25
+ // pool_size: 10,
26
+ // conn_timeout: 30
27
+ },
28
+
29
+ ...
30
+ };
31
+
32
+ ```
33
+
34
+ used in service:
35
+
36
+ ```js
37
+ import { Scheduled, SchedulerLock } from "koatty_schedule";
38
+
39
+ export class TestService {
40
+
41
+ @Scheduled("0 * * * * *")
42
+ @SchedulerLock("testCron") //locker
43
+ Test(){
44
+ //todo
45
+ }
46
+ }
47
+
48
+ ```
package/dist/index.d.ts CHANGED
@@ -1,69 +1,76 @@
1
- /**
2
- * @ author: richen
3
- * @ copyright: Copyright (c) - <richenlin(at)gmail.com>
4
- * @ license: MIT
5
- * @ version: 2020-07-06 10:30:11
6
- */
7
- import "reflect-metadata";
8
- import { Application } from "koatty_container";
9
- interface LockerInterface {
10
- getClient?: () => Promise<any>;
11
- lock?: (key: string, expire?: number) => Promise<boolean>;
12
- waitLock?: (key: string, expire: number, interval?: number, waitTime?: number) => Promise<boolean>;
13
- unLock?: (key: string) => Promise<boolean>;
14
- }
15
- /**
16
- * get instances of cacheStore
17
- *
18
- * @export
19
- * @param {Application} app
20
- * @returns {*} {CacheStore}
21
- */
22
- export declare function GetScheduleLocker(app: Application): Promise<LockerInterface>;
23
- /**
24
- * Schedule task
25
- *
26
- * @export
27
- * @param {string} cron
28
- * * Seconds: 0-59
29
- * * Minutes: 0-59
30
- * * Hours: 0-23
31
- * * Day of Month: 1-31
32
- * * Months: 0-11 (Jan-Dec)
33
- * * Day of Week: 0-6 (Sun-Sat)
34
- *
35
- * @returns {MethodDecorator}
36
- */
37
- export declare function Scheduled(cron: string): MethodDecorator;
38
- /**
39
- * Redis-based distributed locks. Redis server config from db.ts.
40
- *
41
- * @export
42
- * @param {string} [name] The locker name. If name is duplicated, lock sharing contention will result.
43
- * @param {number} [lockTimeOut] Automatic release of lock within a limited maximum time.
44
- * @param {number} [waitLockInterval] Try to acquire lock every interval time(millisecond).
45
- * @param {number} [waitLockTimeOut] When using more than TimeOut(millisecond) still fails to get the lock and return failure.
46
- *
47
- * @returns {MethodDecorator}
48
- */
49
- export declare function SchedulerLock(name?: string, lockTimeOut?: number, waitLockInterval?: number, waitLockTimeOut?: number): MethodDecorator;
50
- /**
51
- * Redis-based distributed locks. Redis server config from db.ts.
52
- *
53
- * @export
54
- * @param {string} [name] The locker name. If name is duplicated, lock sharing contention will result.
55
- * @param {number} [lockTimeOut] Automatic release of lock within a limited maximum time.
56
- * @param {number} [waitLockInterval] Try to acquire lock every interval time(millisecond).
57
- * @param {number} [waitLockTimeOut] When using more than TimeOut(millisecond) still fails to get the lock and return failure.
58
- *
59
- * @returns {MethodDecorator}
60
- */
61
- export declare const Lock: typeof SchedulerLock;
62
- /**
63
- * Inject schedule job
64
- *
65
- * @export
66
- * @param {*} target
67
- */
68
- export declare function injectSchedule(target: any): void;
69
- export {};
1
+ /*!
2
+ * @Author: richen
3
+ * @Date: 2022-05-27 10:10:24
4
+ * @License: BSD (3-Clause)
5
+ * @Copyright (c) - <richenlin(at)gmail.com>
6
+ * @HomePage: https://koatty.org/
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;
26
+
27
+ /**
28
+ * Redis-based distributed locks. Redis server config from db.ts.
29
+ *
30
+ * @export
31
+ * @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.
35
+ *
36
+ * @returns {MethodDecorator}
37
+ */
38
+ export declare const Lock: typeof SchedulerLock;
39
+
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>;
45
+ }
46
+
47
+ /**
48
+ * Schedule task
49
+ *
50
+ * @export
51
+ * @param {string} cron
52
+ * * Seconds: 0-59
53
+ * * Minutes: 0-59
54
+ * * Hours: 0-23
55
+ * * 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.
71
+ *
72
+ * @returns {MethodDecorator}
73
+ */
74
+ export declare function SchedulerLock(name?: string, lockTimeOut?: number, waitLockInterval?: number, waitLockTimeOut?: number): MethodDecorator;
75
+
76
+ export { }