@antelopejs/redis 1.0.3 → 1.1.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/README.md +86 -44
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +52 -27
package/README.md
CHANGED
|
@@ -1,75 +1,117 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
# @antelopejs/redis
|
|
1
|
+
# `@antelopejs/redis`
|
|
4
2
|
|
|
5
3
|
<div align="center">
|
|
6
|
-
<a href="https://www.npmjs.com/package/@antelopejs/redis"><img alt="
|
|
7
|
-
<a href="./LICENSE"><img alt="License" src="https://img.shields.io/npm/l/@antelopejs/redis
|
|
8
|
-
<a href="https://discord.gg/
|
|
9
|
-
<a href="https://antelopejs.com/
|
|
4
|
+
<a href="https://www.npmjs.com/package/@antelopejs/redis"><img data-illustration alt="npm" src="https://img.shields.io/npm/v/@antelopejs/redis?style=for-the-badge&labelColor=000000&color=000000"></a>
|
|
5
|
+
<a href="./LICENSE"><img data-illustration alt="License" src="https://img.shields.io/npm/l/@antelopejs/redis?style=for-the-badge&labelColor=000000&color=000000"></a>
|
|
6
|
+
<a href="https://discord.gg/g4pFt6eXqu"><img data-illustration alt="Discord" src="https://img.shields.io/badge/Discord-18181B?logo=discord&style=for-the-badge&color=000000"></a>
|
|
7
|
+
<a href="https://interfaces.antelopejs.com/docs/redis/introduction"><img data-illustration alt="Documentation" src="https://img.shields.io/badge/Docs-18181B?style=for-the-badge&color=000000"></a>
|
|
10
8
|
</div>
|
|
11
9
|
|
|
12
|
-
|
|
10
|
+
The Redis module of AntelopeJS. It connects one shared [`ioredis`](https://github.com/redis/ioredis) client and serves it to the Redis and Redis Scheduler interfaces.
|
|
11
|
+
|
|
12
|
+
## Interfaces
|
|
13
|
+
|
|
14
|
+
| Interface | Documentation |
|
|
15
|
+
| -------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- |
|
|
16
|
+
| [`@antelopejs/interface-redis`](https://github.com/AntelopeJS/interface-redis) | [Redis](https://interfaces.antelopejs.com/docs/redis/introduction) |
|
|
17
|
+
| [`@antelopejs/interface-redis-scheduler`](https://github.com/AntelopeJS/interface-redis-scheduler) | [Redis Scheduler](https://interfaces.antelopejs.com/docs/redis-scheduler/introduction) |
|
|
18
|
+
|
|
19
|
+
The scheduler runs inside its interface package on top of the Redis client, so it needs no module besides this one.
|
|
13
20
|
|
|
14
|
-
##
|
|
21
|
+
## Install
|
|
15
22
|
|
|
16
23
|
```bash
|
|
17
24
|
ajs project modules add @antelopejs/redis
|
|
18
25
|
```
|
|
19
26
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
This module implements two key interfaces:
|
|
27
|
+
The command writes the module's default configuration, which connects to `redis://localhost:6379`.
|
|
23
28
|
|
|
24
|
-
|
|
25
|
-
- **Redis Scheduler Interface**: Redis-based distributed task scheduler with job queuing and automatic retries.
|
|
29
|
+
## Configuration
|
|
26
30
|
|
|
27
|
-
|
|
31
|
+
```typescript [antelope.config.ts]
|
|
32
|
+
import { defineConfig } from "@antelopejs/interface-core/config";
|
|
33
|
+
|
|
34
|
+
export default defineConfig({
|
|
35
|
+
name: "my-project",
|
|
36
|
+
modules: {
|
|
37
|
+
redis: {
|
|
38
|
+
source: {
|
|
39
|
+
type: "package",
|
|
40
|
+
package: "@antelopejs/redis",
|
|
41
|
+
version: "^1.0.3",
|
|
42
|
+
},
|
|
43
|
+
config: {
|
|
44
|
+
url: "redis://localhost:6379",
|
|
45
|
+
useMock: false,
|
|
46
|
+
lazyConnect: true,
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
envOverrides: {
|
|
51
|
+
REDIS_URL: "modules.redis.config.url",
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
```
|
|
28
55
|
|
|
29
|
-
|
|
|
30
|
-
|
|
|
31
|
-
|
|
|
32
|
-
|
|
|
56
|
+
| Key | Description |
|
|
57
|
+
| ------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
58
|
+
| `url` | Redis connection URL. Optional. Without it, the client uses the options below, or `localhost:6379`. |
|
|
59
|
+
| `useMock` | Serves an in-memory [`ioredis-mock`](https://github.com/stipsan/ioredis-mock) client instead of connecting, and ignores every other key. For tests only. |
|
|
60
|
+
| any other key | Passed to the client as [`ioredis` options](https://github.com/redis/ioredis#connect-to-redis), such as `host`, `port`, `password`, `db`, `tls` or `lazyConnect`. |
|
|
33
61
|
|
|
34
|
-
|
|
62
|
+
The module creates the client when it starts, and quits it when it stops. With `lazyConnect: true`, the module waits for the connection before it serves the client.
|
|
35
63
|
|
|
36
|
-
|
|
64
|
+
## Quick start
|
|
37
65
|
|
|
38
|
-
|
|
39
|
-
- Task scheduling with retry capabilities
|
|
66
|
+
In the module that uses Redis, add the interface:
|
|
40
67
|
|
|
41
|
-
|
|
68
|
+
```bash
|
|
69
|
+
pnpm add @antelopejs/interface-redis
|
|
70
|
+
```
|
|
42
71
|
|
|
43
|
-
|
|
72
|
+
```typescript
|
|
73
|
+
import { GetClient } from "@antelopejs/interface-redis";
|
|
44
74
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
"lazyConnect": true
|
|
49
|
-
}
|
|
75
|
+
const client = await GetClient();
|
|
76
|
+
await client.set("greeting", "hello", "EX", 60);
|
|
77
|
+
const greeting = await client.get("greeting");
|
|
50
78
|
```
|
|
51
79
|
|
|
52
|
-
|
|
80
|
+
`GetClient()` waits until the module has started and set its client. For distributed jobs, add `@antelopejs/interface-redis-scheduler` and read its [documentation](https://interfaces.antelopejs.com/docs/redis-scheduler/introduction).
|
|
53
81
|
|
|
54
|
-
|
|
82
|
+
## Documentation
|
|
55
83
|
|
|
56
|
-
-
|
|
57
|
-
-
|
|
84
|
+
- [Redis](https://interfaces.antelopejs.com/docs/redis/introduction) documents the `@antelopejs/interface-redis` contract that this module implements.
|
|
85
|
+
- [Redis Scheduler](https://interfaces.antelopejs.com/docs/redis-scheduler/introduction) documents the `@antelopejs/interface-redis-scheduler` contract that this module implements.
|
|
86
|
+
- [Configuration](https://framework.antelopejs.com/docs/concepts/configuration) documents module sources, `config` blocks and config variables in `antelope.config.ts`.
|
|
58
87
|
|
|
59
|
-
##
|
|
88
|
+
## Compatibility
|
|
60
89
|
|
|
61
|
-
|
|
90
|
+
<!-- antelopejs-docs-compat:start -->
|
|
62
91
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
92
|
+
| Package | Supported | Tested with |
|
|
93
|
+
| --------------------------------------- | ---------------- | ----------- |
|
|
94
|
+
| `@antelopejs/interface-core` | `>=0.2.4 <1.0.0` | `0.2.4` |
|
|
95
|
+
| `@antelopejs/interface-redis` | `>=0.0.9 <1.0.0` | `0.0.9` |
|
|
96
|
+
| `@antelopejs/interface-redis-scheduler` | `>=0.0.8 <1.0.0` | `0.0.8` |
|
|
97
|
+
|
|
98
|
+
<!-- antelopejs-docs-compat:end -->
|
|
66
99
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
100
|
+
`.nvmrc` sets the Node.js release for development, and the `dependencies` of `package.json` set the `ioredis` range.
|
|
101
|
+
|
|
102
|
+
## Contributing
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
pnpm install
|
|
106
|
+
pnpm dev # run the playground/ project against redis://127.0.0.1:6379
|
|
107
|
+
pnpm lint
|
|
108
|
+
pnpm format:check
|
|
109
|
+
pnpm knip
|
|
110
|
+
pnpm test # build, then ajs module test with ioredis-mock
|
|
71
111
|
```
|
|
72
112
|
|
|
113
|
+
The tests need no Redis server. Read the [contribution guidelines](CONTRIBUTING.md) before you open a pull request.
|
|
114
|
+
|
|
73
115
|
## License
|
|
74
116
|
|
|
75
|
-
|
|
117
|
+
[Apache-2.0](LICENSE)
|
package/dist/index.js
CHANGED
|
@@ -40,8 +40,8 @@ exports.construct = construct;
|
|
|
40
40
|
exports.destroy = destroy;
|
|
41
41
|
exports.start = start;
|
|
42
42
|
exports.stop = stop;
|
|
43
|
-
const interface_redis_1 = require("@antelopejs/interface-redis");
|
|
44
43
|
const ioredis_1 = __importDefault(require("ioredis"));
|
|
44
|
+
const interface_redis_1 = require("@antelopejs/interface-redis");
|
|
45
45
|
let redisConfig;
|
|
46
46
|
function construct(config) {
|
|
47
47
|
redisConfig = config;
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,8BAEC;AAED,0BAAkC;AAElC,sBAMC;AAED,oBAIC;AA3BD,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,8BAEC;AAED,0BAAkC;AAElC,sBAMC;AAED,oBAIC;AA3BD,sDAAmD;AACnD,iEAAuD;AAOvD,IAAI,WAAwB,CAAC;AAC7B,SAAgB,SAAS,CAAC,MAAmB;IAC3C,WAAW,GAAG,MAAM,CAAC;AACvB,CAAC;AAED,SAAgB,OAAO,KAAU,CAAC;AAE3B,KAAK,UAAU,KAAK;IACzB,MAAM,MAAM,GAAG,MAAM,iBAAiB,CAAC,WAAW,CAAC,CAAC;IACpD,IAAI,WAAW,CAAC,OAAO,IAAI,WAAW,CAAC,WAAW,EAAE,CAAC;QACnD,MAAM,MAAM,CAAC,OAAO,EAAE,CAAC;IACzB,CAAC;IACD,0BAAQ,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;AAC7B,CAAC;AAEM,KAAK,UAAU,IAAI;IACxB,MAAM,MAAM,GAAG,MAAM,0BAAQ,CAAC,MAAM,CAAC;IACrC,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;IACpB,KAAK,0BAAQ,CAAC,WAAW,EAAE,CAAC;AAC9B,CAAC;AAED,KAAK,UAAU,iBAAiB,CAAC,MAAmB;IAClD,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;QACnB,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,wDAAa,cAAc,GAAC,CAAC;QAC5D,OAAO,IAAI,SAAS,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC;IAC9C,CAAC;IACD,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC,EAAE,GAAG,OAAO,EAAE,GAAG,MAAM,CAAC;IAC/C,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,OAAO,IAAI,iBAAK,CAAC,OAAO,CAAC,CAAC;IAC5B,CAAC;IACD,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACtC,OAAO,IAAI,iBAAK,CAAC,GAAG,CAAC,CAAC;IACxB,CAAC;IACD,OAAO,IAAI,iBAAK,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;AACjC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,64 +1,89 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antelopejs/redis",
|
|
3
|
-
"version": "1.0
|
|
4
|
-
"description": "Redis module
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"description": "Redis module for AntelopeJS, implementing the Redis and Redis Scheduler interfaces with ioredis",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"antelopejs",
|
|
7
|
-
"redis",
|
|
8
7
|
"cache",
|
|
9
|
-
"
|
|
10
|
-
"
|
|
8
|
+
"ioredis",
|
|
9
|
+
"redis",
|
|
10
|
+
"scheduler"
|
|
11
11
|
],
|
|
12
|
+
"homepage": "https://interfaces.antelopejs.com/docs/redis/introduction",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/AntelopeJS/redis/issues"
|
|
15
|
+
},
|
|
16
|
+
"license": "Apache-2.0",
|
|
12
17
|
"repository": {
|
|
13
18
|
"type": "git",
|
|
14
19
|
"url": "git+https://github.com/AntelopeJS/redis.git"
|
|
15
20
|
},
|
|
16
|
-
"main": "dist/index.js",
|
|
17
21
|
"files": [
|
|
18
22
|
"dist"
|
|
19
23
|
],
|
|
24
|
+
"main": "dist/index.js",
|
|
20
25
|
"publishConfig": {
|
|
21
|
-
"access": "public"
|
|
26
|
+
"access": "public",
|
|
27
|
+
"provenance": true
|
|
22
28
|
},
|
|
23
|
-
"license": "Apache-2.0",
|
|
24
|
-
"packageManager": "pnpm@10.6.5",
|
|
25
29
|
"scripts": {
|
|
26
30
|
"build": "rimraf dist && tsc",
|
|
27
31
|
"dev": "ajs project run -w -p playground --inspect",
|
|
28
|
-
"format": "
|
|
29
|
-
"lint:fix": "
|
|
30
|
-
"lint": "
|
|
32
|
+
"format": "oxfmt .",
|
|
33
|
+
"lint:fix": "oxlint --fix",
|
|
34
|
+
"lint": "oxlint",
|
|
31
35
|
"prepack": "pnpm run build",
|
|
32
36
|
"release": "pnpm run lint && pnpm run test && pnpm run prepack && release-it",
|
|
33
|
-
"test": "pnpm run build && ajs module test ."
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
"
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
"
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
"
|
|
37
|
+
"test": "pnpm run build && ajs module test .",
|
|
38
|
+
"format:check": "oxfmt --check .",
|
|
39
|
+
"knip": "knip",
|
|
40
|
+
"prepare": "if git rev-parse --is-inside-work-tree >/dev/null 2>&1 && command -v lefthook >/dev/null 2>&1; then lefthook install; fi",
|
|
41
|
+
"checks": "antelopejs-checks",
|
|
42
|
+
"size": "antelopejs-check-size",
|
|
43
|
+
"sync": "antelopejs-sync",
|
|
44
|
+
"sync:check": "antelopejs-sync --check",
|
|
45
|
+
"typecheck": "tsc --noEmit",
|
|
46
|
+
"suppressions": "antelopejs-suppressions",
|
|
47
|
+
"suppressions:update": "antelopejs-suppressions --update"
|
|
44
48
|
},
|
|
45
49
|
"dependencies": {
|
|
46
|
-
"@antelopejs/interface-core": ">=0.
|
|
47
|
-
"@antelopejs/interface-redis": ">=0.0.
|
|
48
|
-
"@antelopejs/interface-redis-scheduler": ">=0.0.
|
|
50
|
+
"@antelopejs/interface-core": ">=0.2.4 <1.0.0",
|
|
51
|
+
"@antelopejs/interface-redis": ">=0.0.9 <1.0.0",
|
|
52
|
+
"@antelopejs/interface-redis-scheduler": ">=0.0.8 <1.0.0",
|
|
49
53
|
"ioredis": "^5.10.1",
|
|
50
54
|
"ioredis-mock": "^8.13.1"
|
|
51
55
|
},
|
|
52
56
|
"devDependencies": {
|
|
53
|
-
"@
|
|
57
|
+
"@antelopejs/core": "^1.16.0",
|
|
58
|
+
"@antelopejs/tooling-configs": "^0.2.17",
|
|
54
59
|
"@types/chai": "^4.3.20",
|
|
55
60
|
"@types/ioredis-mock": "^8.2.7",
|
|
56
61
|
"@types/mocha": "^10.0.10",
|
|
57
62
|
"@types/node": "^22.19.15",
|
|
58
63
|
"chai": "^4.5.0",
|
|
64
|
+
"eslint-plugin-perfectionist": "^5.11.0",
|
|
65
|
+
"knip": "^6.34.0",
|
|
66
|
+
"lefthook": "^2.2.2",
|
|
67
|
+
"oxfmt": "^0.66.0",
|
|
68
|
+
"oxlint": "1.81.0",
|
|
69
|
+
"oxlint-tsgolint": "^7.0.2001",
|
|
59
70
|
"release-it": "^19.2.4",
|
|
60
71
|
"release-it-changelogen": "^0.1.0",
|
|
61
72
|
"rimraf": "^6.1.3",
|
|
62
73
|
"typescript": "^5.9.3"
|
|
74
|
+
},
|
|
75
|
+
"packageManager": "pnpm@10.6.5",
|
|
76
|
+
"antelopeJs": {
|
|
77
|
+
"implements": [
|
|
78
|
+
"@antelopejs/interface-redis",
|
|
79
|
+
"@antelopejs/interface-redis-scheduler"
|
|
80
|
+
],
|
|
81
|
+
"defaultConfig": {
|
|
82
|
+
"url": "redis://localhost:6379"
|
|
83
|
+
},
|
|
84
|
+
"test": "src/test/antelope.test.ts",
|
|
85
|
+
"docs": {
|
|
86
|
+
"standard": true
|
|
87
|
+
}
|
|
63
88
|
}
|
|
64
89
|
}
|