@appweaver/redis 2.0.2 → 2.1.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/package.json +3 -3
- package/redis-memory.js +9 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@appweaver/redis",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.1",
|
|
4
4
|
"description": "Appweaver - the backend framework for AI-first development (@redis)",
|
|
5
5
|
"author": "Luka Matosevic",
|
|
6
6
|
"license": "MIT",
|
|
@@ -44,8 +44,8 @@
|
|
|
44
44
|
"flatted": "3.4.2"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
|
-
"@appweaver/common": "^2.
|
|
48
|
-
"@appweaver/core": "^2.
|
|
47
|
+
"@appweaver/common": "^2.1.1",
|
|
48
|
+
"@appweaver/core": "^2.1.1"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@appweaver/common": "^1.12.2",
|
package/redis-memory.js
CHANGED
|
@@ -6,6 +6,7 @@ const ioredis_1 = require("ioredis");
|
|
|
6
6
|
const flatted_1 = require("flatted");
|
|
7
7
|
const common_1 = require("@appweaver/common");
|
|
8
8
|
const config_1 = require("./config");
|
|
9
|
+
const logger = (0, common_1.createLogger)('memory');
|
|
9
10
|
class RedisMemory extends common_1.Memory {
|
|
10
11
|
/** @internal */
|
|
11
12
|
_options;
|
|
@@ -123,20 +124,25 @@ class RedisMemory extends common_1.Memory {
|
|
|
123
124
|
/** @internal */
|
|
124
125
|
monitorConnection(client) {
|
|
125
126
|
const name = client.options.connectionName ?? 'redis';
|
|
127
|
+
let connected = false;
|
|
126
128
|
let lost = false;
|
|
127
129
|
// Logs only the first error of an outage, the client emits one on every
|
|
128
130
|
// failed reconnection attempt
|
|
129
131
|
client.on('error', (error) => {
|
|
130
132
|
if (!lost) {
|
|
131
133
|
lost = true;
|
|
132
|
-
|
|
134
|
+
logger.error(error, `Redis connection '${name}' is down, reconnecting in background`);
|
|
133
135
|
}
|
|
134
136
|
});
|
|
135
137
|
client.on('ready', () => {
|
|
136
138
|
if (lost) {
|
|
137
|
-
|
|
138
|
-
common_1.logger.info(`Redis connection '${name}' is restored`);
|
|
139
|
+
logger.info(`Redis connection '${name}' is restored`);
|
|
139
140
|
}
|
|
141
|
+
else if (!connected) {
|
|
142
|
+
logger.info(`Redis connection '${name}' is established`);
|
|
143
|
+
}
|
|
144
|
+
connected = true;
|
|
145
|
+
lost = false;
|
|
140
146
|
});
|
|
141
147
|
}
|
|
142
148
|
/** @internal */
|