koatty_schedule 1.6.0 → 1.6.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.
- package/.rollup.config.js +59 -62
- package/CHANGELOG.md +29 -27
- package/LICENSE +29 -29
- package/README.md +47 -47
- package/dist/LICENSE +29 -29
- package/dist/README.md +47 -47
- package/dist/index.d.ts +31 -44
- package/dist/index.js +1768 -490
- package/dist/index.mjs +1755 -472
- package/dist/package.json +100 -90
- package/package.json +100 -90
package/.rollup.config.js
CHANGED
|
@@ -1,63 +1,60 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* @Description:
|
|
3
|
-
* @Usage:
|
|
4
|
-
* @Author: richen
|
|
5
|
-
* @Date: 2021-12-17 10:20:44
|
|
6
|
-
* @LastEditTime:
|
|
7
|
-
*/
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
})
|
|
61
|
-
]
|
|
62
|
-
}
|
|
1
|
+
/*
|
|
2
|
+
* @Description:
|
|
3
|
+
* @Usage:
|
|
4
|
+
* @Author: richen
|
|
5
|
+
* @Date: 2021-12-17 10:20:44
|
|
6
|
+
* @LastEditTime: 2024-11-04 22:04:45
|
|
7
|
+
*/
|
|
8
|
+
import commonjs from '@rollup/plugin-commonjs';
|
|
9
|
+
import json from "@rollup/plugin-json";
|
|
10
|
+
import resolve from '@rollup/plugin-node-resolve';
|
|
11
|
+
import { builtinModules } from 'module';
|
|
12
|
+
import del from "rollup-plugin-delete";
|
|
13
|
+
import typescript from 'rollup-plugin-typescript2';
|
|
14
|
+
// import babel from '@rollup/plugin-babel';
|
|
15
|
+
const pkg = require('./package.json');
|
|
16
|
+
|
|
17
|
+
export default [
|
|
18
|
+
{
|
|
19
|
+
input: './src/index.ts',
|
|
20
|
+
output: [
|
|
21
|
+
{
|
|
22
|
+
format: 'cjs',
|
|
23
|
+
file: './dist/index.js',
|
|
24
|
+
banner: require('./scripts/copyright'),
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
format: 'es',
|
|
28
|
+
file: './dist/index.mjs',
|
|
29
|
+
banner: require('./scripts/copyright'),
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
plugins: [
|
|
33
|
+
del({ targets: ["dist/*", "temp/*", "docs/api"] }),
|
|
34
|
+
// babel({
|
|
35
|
+
// babelHelpers: "runtime",
|
|
36
|
+
// configFile: './babel.config.js',
|
|
37
|
+
// exclude: 'node_modules/**',
|
|
38
|
+
// }),
|
|
39
|
+
json(),
|
|
40
|
+
resolve({
|
|
41
|
+
preferBuiltins: true, // 优先选择内置模块
|
|
42
|
+
}),
|
|
43
|
+
commonjs(),
|
|
44
|
+
typescript({
|
|
45
|
+
tsconfigOverride: {
|
|
46
|
+
compilerOptions: {
|
|
47
|
+
declaration: false,
|
|
48
|
+
declarationMap: false,
|
|
49
|
+
module: "ESNext"
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
})
|
|
53
|
+
],
|
|
54
|
+
external: [
|
|
55
|
+
...builtinModules, // 排除 Node.js 内置模块
|
|
56
|
+
...Object.keys(pkg.dependencies || {}), // 排除 package.json 中的外部依赖
|
|
57
|
+
],
|
|
58
|
+
},
|
|
59
|
+
|
|
63
60
|
]
|
package/CHANGELOG.md
CHANGED
|
@@ -2,30 +2,32 @@
|
|
|
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
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
### [1.5.
|
|
10
|
-
|
|
11
|
-
### [1.5.
|
|
12
|
-
|
|
13
|
-
### [1.5.
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
### [1.5.
|
|
24
|
-
|
|
25
|
-
### [1.5.
|
|
26
|
-
|
|
27
|
-
### [1.5.
|
|
28
|
-
|
|
29
|
-
### [1.
|
|
30
|
-
|
|
31
|
-
### [1.4.
|
|
5
|
+
### [1.6.2](https://github.com/thinkkoa/koatty_schedule/compare/v1.6.0...v1.6.2) (2024-11-07)
|
|
6
|
+
|
|
7
|
+
## [1.6.0](https://github.com/thinkkoa/koatty_schedule/compare/v1.5.11...v1.6.0) (2023-12-20)
|
|
8
|
+
|
|
9
|
+
### [1.5.11](https://github.com/thinkkoa/koatty_schedule/compare/v1.5.10...v1.5.11) (2023-07-28)
|
|
10
|
+
|
|
11
|
+
### [1.5.10](https://github.com/thinkkoa/koatty_schedule/compare/v1.5.8...v1.5.10) (2023-01-13)
|
|
12
|
+
|
|
13
|
+
### [1.5.8](https://github.com/thinkkoa/koatty_schedule/compare/v1.5.7...v1.5.8) (2022-11-03)
|
|
14
|
+
|
|
15
|
+
### [1.5.7](https://github.com/thinkkoa/koatty_schedule/compare/v1.5.6...v1.5.7) (2022-09-05)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
* update ([8eb40be](https://github.com/thinkkoa/koatty_schedule/commit/8eb40be4f0778d218a2a8b9a9370ffbe26c9e884))
|
|
21
|
+
* upgrade deps ([51a68af](https://github.com/thinkkoa/koatty_schedule/commit/51a68af12437a08e3a5468b27b57ae597f66695d))
|
|
22
|
+
|
|
23
|
+
### [1.5.6](https://github.com/thinkkoa/koatty_schedule/compare/v1.5.5...v1.5.6) (2022-05-27)
|
|
24
|
+
|
|
25
|
+
### [1.5.5](https://github.com/thinkkoa/koatty_schedule/compare/v1.5.4...v1.5.5) (2022-03-02)
|
|
26
|
+
|
|
27
|
+
### [1.5.4](https://github.com/thinkkoa/koatty_schedule/compare/v1.5.2...v1.5.4) (2021-12-09)
|
|
28
|
+
|
|
29
|
+
### [1.5.2](https://github.com/thinkkoa/koatty_schedule/compare/v1.4.10...v1.5.2) (2021-12-02)
|
|
30
|
+
|
|
31
|
+
### [1.4.10](https://github.com/thinkkoa/koatty_schedule/compare/v1.4.8...v1.4.10) (2021-11-23)
|
|
32
|
+
|
|
33
|
+
### [1.4.8](https://github.com/thinkkoa/koatty_schedule/compare/v1.4.6...v1.4.8) (2021-11-20)
|
package/LICENSE
CHANGED
|
@@ -1,29 +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.
|
|
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/README.md
CHANGED
|
@@ -1,48 +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
|
-
|
|
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
48
|
```
|
package/dist/LICENSE
CHANGED
|
@@ -1,29 +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.
|
|
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
CHANGED
|
@@ -1,48 +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
|
-
|
|
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
48
|
```
|
package/dist/index.d.ts
CHANGED
|
@@ -1,47 +1,46 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* @Author: richen
|
|
3
|
-
* @Date:
|
|
3
|
+
* @Date: 2024-11-07 16:50:50
|
|
4
4
|
* @License: BSD (3-Clause)
|
|
5
5
|
* @Copyright (c) - <richenlin(at)gmail.com>
|
|
6
6
|
* @HomePage: https://koatty.org/
|
|
7
7
|
*/
|
|
8
|
-
import {
|
|
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} [
|
|
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
|
|
20
|
+
export declare function RedLock(name?: string, options?: RedLockOptions): MethodDecorator;
|
|
39
21
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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
|
+
* If there is a lock timeout, renew the lock and retry execution,
|
|
37
|
+
* with a maximum of maxRetry attempts.
|
|
38
|
+
*/
|
|
39
|
+
renewCount?: number;
|
|
40
|
+
/**
|
|
41
|
+
* redis config
|
|
42
|
+
*/
|
|
43
|
+
RedisOptions: RedisOptions;
|
|
45
44
|
}
|
|
46
45
|
|
|
47
46
|
/**
|
|
@@ -49,28 +48,16 @@ declare interface LockerInterface {
|
|
|
49
48
|
*
|
|
50
49
|
* @export
|
|
51
50
|
* @param {string} cron
|
|
51
|
+
* @param {string} _timezone
|
|
52
52
|
* * Seconds: 0-59
|
|
53
53
|
* * Minutes: 0-59
|
|
54
54
|
* * Hours: 0-23
|
|
55
55
|
* * Day of Month: 1-31
|
|
56
|
-
* * Months:
|
|
57
|
-
* * Day of Week:
|
|
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.
|
|
56
|
+
* * Months: 1-12 (Jan-Dec)
|
|
57
|
+
* * Day of Week: 1-7 (Sun-Sat)
|
|
71
58
|
*
|
|
72
59
|
* @returns {MethodDecorator}
|
|
73
60
|
*/
|
|
74
|
-
export declare function
|
|
61
|
+
export declare function Scheduled(cron: string, _timezone?: string): MethodDecorator;
|
|
75
62
|
|
|
76
63
|
export { }
|