@eleven-am/pondsocket 0.1.188 → 0.1.190
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/abstracts/redisClient.js +23 -42
- package/package.json +7 -7
package/abstracts/redisClient.js
CHANGED
|
@@ -33,7 +33,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
33
33
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
34
34
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
35
35
|
};
|
|
36
|
-
var _RedisClient_instances, _RedisClient_heartbeatInterval, _RedisClient_cleanupInterval, _RedisClient_instanceTtl, _RedisClient_redisClient, _RedisClient_pubClient, _RedisClient_subClient, _RedisClient_instanceId, _RedisClient_assignsPublisher, _RedisClient_presencePublisher, _RedisClient_userLeavesPublisher, _RedisClient_channelMessagePublisher, _RedisClient_stateSyncPublisher, _RedisClient_heartbeatTimer, _RedisClient_cleanupTimer, _RedisClient_presence_changes_channel_get, _RedisClient_assigns_changes_channel_get, _RedisClient_channel_messages_channel_get, _RedisClient_user_leaves_channel_get, _RedisClient_handleErrors, _RedisClient_getPresenceCacheChannel, _RedisClient_getAssignsCacheChannel, _RedisClient_publishPresenceChange, _RedisClient_publishAssignsChange, _RedisClient_publishChannelMessage, _RedisClient_publishUserLeave, _RedisClient_registerInstance, _RedisClient_unregisterInstance, _RedisClient_unsubscribeFromChannels, _RedisClient_subscribeToChannels, _RedisClient_startHeartbeat, _RedisClient_startPeriodicCleanup, _RedisClient_performConsistencyCheck, _RedisClient_handleRedisMessage, _RedisClient_publishCacheMessage, _RedisClient_emitStateSyncEvent, _RedisClient_subscribeToCacheChanges, _RedisClient_subscribeToChannelMessages, _RedisClient_subscribeToUserLeaves, _RedisClient_subscribeToStateSync, _RedisClient_handleExit, _RedisClient_deleteKeysByPattern;
|
|
36
|
+
var _RedisClient_instances, _RedisClient_heartbeatInterval, _RedisClient_cleanupInterval, _RedisClient_instanceTtl, _RedisClient_redisClient, _RedisClient_pubClient, _RedisClient_subClient, _RedisClient_instanceId, _RedisClient_assignsPublisher, _RedisClient_presencePublisher, _RedisClient_userLeavesPublisher, _RedisClient_channelMessagePublisher, _RedisClient_stateSyncPublisher, _RedisClient_heartbeatTimer, _RedisClient_cleanupTimer, _RedisClient_presence_changes_channel_get, _RedisClient_assigns_changes_channel_get, _RedisClient_channel_messages_channel_get, _RedisClient_user_leaves_channel_get, _RedisClient_handleErrors, _RedisClient_getPresenceCacheChannel, _RedisClient_getAssignsCacheChannel, _RedisClient_publishPresenceChange, _RedisClient_publishAssignsChange, _RedisClient_publishChannelMessage, _RedisClient_publishUserLeave, _RedisClient_registerInstance, _RedisClient_unregisterInstance, _RedisClient_unsubscribeFromChannels, _RedisClient_subscribeToChannels, _RedisClient_startHeartbeat, _RedisClient_startPeriodicCleanup, _RedisClient_performConsistencyCheck, _RedisClient_handleRedisMessage, _RedisClient_publishCacheMessage, _RedisClient_emitStateSyncEvent, _RedisClient_subscribeToCacheChanges, _RedisClient_subscribeToChannelMessages, _RedisClient_subscribeToUserLeaves, _RedisClient_subscribeToStateSync, _RedisClient_handleExit, _RedisClient_deleteKeysByPattern, _RedisClient_generateCache;
|
|
37
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
38
|
exports.RedisClient = void 0;
|
|
39
39
|
const pondsocket_common_1 = require("@eleven-am/pondsocket-common");
|
|
@@ -221,45 +221,22 @@ _RedisClient_heartbeatInterval = new WeakMap(), _RedisClient_cleanupInterval = n
|
|
|
221
221
|
}), __classPrivateFieldGet(this, _RedisClient_cleanupInterval, "f")), "f");
|
|
222
222
|
}, _RedisClient_performConsistencyCheck = function _RedisClient_performConsistencyCheck() {
|
|
223
223
|
return __awaiter(this, void 0, void 0, function* () {
|
|
224
|
-
const
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
local instance_id, endpoint_id, channel_id = parts[2], parts[3], parts[4]
|
|
241
|
-
|
|
242
|
-
if not active_set[instance_id] then
|
|
243
|
-
table.insert(inactive_keys, key)
|
|
244
|
-
local pair = endpoint_id .. ':' .. channel_id
|
|
245
|
-
unique_pairs[pair] = true
|
|
246
|
-
end
|
|
247
|
-
end
|
|
248
|
-
|
|
249
|
-
if #inactive_keys > 0 then
|
|
250
|
-
redis.call('DEL', unpack(inactive_keys))
|
|
251
|
-
end
|
|
252
|
-
|
|
253
|
-
local unique_pairs_list = {}
|
|
254
|
-
for pair in pairs(unique_pairs) do
|
|
255
|
-
table.insert(unique_pairs_list, pair)
|
|
256
|
-
end
|
|
257
|
-
|
|
258
|
-
return unique_pairs_list
|
|
259
|
-
`;
|
|
260
|
-
const [response] = yield __classPrivateFieldGet(this, _RedisClient_redisClient, "f").eval(consistencyCheckScript, 0);
|
|
261
|
-
const uniquePairs = Array.isArray(response) ? response : response ? [response] : [];
|
|
262
|
-
const promises = uniquePairs.map((pair) => {
|
|
224
|
+
const activeInstances = yield __classPrivateFieldGet(this, _RedisClient_redisClient, "f").smembers('distributed_instances');
|
|
225
|
+
const allKeys = yield __classPrivateFieldGet(this, _RedisClient_redisClient, "f").keys('*_cache:*');
|
|
226
|
+
const activeSet = new Set(activeInstances);
|
|
227
|
+
const inactiveKeys = [];
|
|
228
|
+
const uniquePairs = new Set();
|
|
229
|
+
for (const key of allKeys) {
|
|
230
|
+
const [, instanceId, endpointId, channelId] = key.split(':');
|
|
231
|
+
if (!activeSet.has(instanceId)) {
|
|
232
|
+
inactiveKeys.push(key);
|
|
233
|
+
uniquePairs.add(`${endpointId}:${channelId}`);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
if (inactiveKeys.length > 0) {
|
|
237
|
+
yield __classPrivateFieldGet(this, _RedisClient_redisClient, "f").del(...inactiveKeys);
|
|
238
|
+
}
|
|
239
|
+
const promises = Array.from(uniquePairs).map((pair) => {
|
|
263
240
|
const [endpointId, channelId] = pair.split(':');
|
|
264
241
|
return __classPrivateFieldGet(this, _RedisClient_instances, "m", _RedisClient_emitStateSyncEvent).call(this, endpointId, channelId);
|
|
265
242
|
});
|
|
@@ -334,8 +311,8 @@ _RedisClient_heartbeatInterval = new WeakMap(), _RedisClient_cleanupInterval = n
|
|
|
334
311
|
endpointId,
|
|
335
312
|
channelId,
|
|
336
313
|
initialFetch,
|
|
337
|
-
presence:
|
|
338
|
-
assigns:
|
|
314
|
+
presence: __classPrivateFieldGet(this, _RedisClient_instances, "m", _RedisClient_generateCache).call(this, presenceData),
|
|
315
|
+
assigns: __classPrivateFieldGet(this, _RedisClient_instances, "m", _RedisClient_generateCache).call(this, assignsData),
|
|
339
316
|
};
|
|
340
317
|
__classPrivateFieldGet(this, _RedisClient_stateSyncPublisher, "f").publish(event);
|
|
341
318
|
});
|
|
@@ -393,4 +370,8 @@ _RedisClient_heartbeatInterval = new WeakMap(), _RedisClient_cleanupInterval = n
|
|
|
393
370
|
}
|
|
394
371
|
} while (cursor !== '0');
|
|
395
372
|
});
|
|
373
|
+
}, _RedisClient_generateCache = function _RedisClient_generateCache(data) {
|
|
374
|
+
const first = Object.entries(JSON.parse(data));
|
|
375
|
+
const second = first.map(([key, value]) => [key, JSON.parse(String(value))]);
|
|
376
|
+
return new Map(second);
|
|
396
377
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eleven-am/pondsocket",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.190",
|
|
4
4
|
"description": "PondSocket is a fast simple socket server",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"socket",
|
|
@@ -34,18 +34,18 @@
|
|
|
34
34
|
"url": "git+https://github.com/Eleven-am/pondSocket.git"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@eleven-am/pondsocket-common": "^0.0.
|
|
37
|
+
"@eleven-am/pondsocket-common": "^0.0.26",
|
|
38
38
|
"ioredis": "^5.4.1",
|
|
39
39
|
"ws": "^8.18.0"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@stylistic/eslint-plugin-ts": "^2.
|
|
42
|
+
"@stylistic/eslint-plugin-ts": "^2.10.1",
|
|
43
43
|
"@types/jest": "^29.5.14",
|
|
44
|
-
"@types/node": "^22.8.
|
|
45
|
-
"@types/ws": "^8.5.
|
|
44
|
+
"@types/node": "^22.8.7",
|
|
45
|
+
"@types/ws": "^8.5.13",
|
|
46
46
|
"@typescript-eslint/eslint-plugin": "^8.11.0",
|
|
47
47
|
"@typescript-eslint/parser": "^8.11.0",
|
|
48
|
-
"eslint": "^8.57.
|
|
48
|
+
"eslint": "^8.57.1",
|
|
49
49
|
"eslint-config-prettier": "^9.1.0",
|
|
50
50
|
"eslint-import-resolver-node": "^0.3.9",
|
|
51
51
|
"eslint-plugin-file-progress": "^1.5.0",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"ts-loader": "^9.5.1",
|
|
61
61
|
"ts-node": "^10.9.2",
|
|
62
62
|
"tsconfig-paths": "^4.2.0",
|
|
63
|
-
"typescript": "^5.6.
|
|
63
|
+
"typescript": "^5.6.3"
|
|
64
64
|
},
|
|
65
65
|
"jest": {
|
|
66
66
|
"moduleFileExtensions": [
|