@resolveio/server-lib 20.12.52 → 20.12.54
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/managers/method.manager.js +82 -7
- package/managers/method.manager.js.map +1 -1
- package/managers/mongo.manager.js +2 -1
- package/managers/mongo.manager.js.map +1 -1
- package/managers/subscription.manager.d.ts +1 -1
- package/managers/subscription.manager.js +12 -5
- package/managers/subscription.manager.js.map +1 -1
- package/package.json +5 -5
|
@@ -38,7 +38,6 @@ export declare class SubscriptionManager {
|
|
|
38
38
|
private _resumeTokenSaveForcePending;
|
|
39
39
|
private _fullResyncPromise;
|
|
40
40
|
private readonly RESUME_TOKEN_COLLECTION;
|
|
41
|
-
private readonly RESUME_TOKEN_DOC_ID;
|
|
42
41
|
private readonly RESUME_TOKEN_SAVE_INTERVAL_MS;
|
|
43
42
|
private latencyBuffer;
|
|
44
43
|
private readonly LATENCY_UPDATE_INTERVAL;
|
|
@@ -70,6 +69,7 @@ export declare class SubscriptionManager {
|
|
|
70
69
|
getActiveSubscriptions(): ActiveSubscriptionModel[];
|
|
71
70
|
private getPublicationCollections;
|
|
72
71
|
private getWatchedDatabases;
|
|
72
|
+
private getResumeTokenDocId;
|
|
73
73
|
private loadResumeToken;
|
|
74
74
|
private saveResumeToken;
|
|
75
75
|
private clearResumeToken;
|
|
@@ -136,7 +136,6 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
136
136
|
this._resumeTokenSaveForcePending = false;
|
|
137
137
|
this._fullResyncPromise = null;
|
|
138
138
|
this.RESUME_TOKEN_COLLECTION = 'subscription-manager-resume-tokens';
|
|
139
|
-
this.RESUME_TOKEN_DOC_ID = 'oplog';
|
|
140
139
|
this.RESUME_TOKEN_SAVE_INTERVAL_MS = 5000;
|
|
141
140
|
// Buffer to store throttled latency updates with timestamps
|
|
142
141
|
this.latencyBuffer = new Map();
|
|
@@ -929,6 +928,13 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
929
928
|
var mainDb = config && typeof config['DATABASE'] === 'string' ? config['DATABASE'] : '';
|
|
930
929
|
return mainDb ? [mainDb] : [];
|
|
931
930
|
};
|
|
931
|
+
SubscriptionManager.prototype.getResumeTokenDocId = function () {
|
|
932
|
+
if (process.env.NODE_APP_INSTANCE) {
|
|
933
|
+
return "oplog:".concat(process.env.NODE_APP_INSTANCE);
|
|
934
|
+
}
|
|
935
|
+
// Fallback: avoid cross-process contention when NODE_APP_INSTANCE is not set.
|
|
936
|
+
return "oplog:".concat(process.pid);
|
|
937
|
+
};
|
|
932
938
|
SubscriptionManager.prototype.loadResumeToken = function () {
|
|
933
939
|
return __awaiter(this, void 0, void 0, function () {
|
|
934
940
|
var db, doc, error_2;
|
|
@@ -940,7 +946,7 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
940
946
|
if (!db) {
|
|
941
947
|
return [2 /*return*/, null];
|
|
942
948
|
}
|
|
943
|
-
return [4 /*yield*/, db.collection(this.RESUME_TOKEN_COLLECTION).findOne({ _id: this.
|
|
949
|
+
return [4 /*yield*/, db.collection(this.RESUME_TOKEN_COLLECTION).findOne({ _id: this.getResumeTokenDocId() })];
|
|
944
950
|
case 1:
|
|
945
951
|
doc = _a.sent();
|
|
946
952
|
return [2 /*return*/, (doc === null || doc === void 0 ? void 0 : doc.token) || null];
|
|
@@ -969,7 +975,7 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
969
975
|
if (!db) {
|
|
970
976
|
return [2 /*return*/];
|
|
971
977
|
}
|
|
972
|
-
return [4 /*yield*/, db.collection(this.RESUME_TOKEN_COLLECTION).updateOne({ _id: this.
|
|
978
|
+
return [4 /*yield*/, db.collection(this.RESUME_TOKEN_COLLECTION).updateOne({ _id: this.getResumeTokenDocId() }, { $set: { token: token, updatedAt: new Date() } }, { upsert: true })];
|
|
973
979
|
case 2:
|
|
974
980
|
_a.sent();
|
|
975
981
|
return [3 /*break*/, 4];
|
|
@@ -993,7 +999,7 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
993
999
|
if (!db) {
|
|
994
1000
|
return [2 /*return*/];
|
|
995
1001
|
}
|
|
996
|
-
return [4 /*yield*/, db.collection(this.RESUME_TOKEN_COLLECTION).deleteOne({ _id: this.
|
|
1002
|
+
return [4 /*yield*/, db.collection(this.RESUME_TOKEN_COLLECTION).deleteOne({ _id: this.getResumeTokenDocId() })];
|
|
997
1003
|
case 1:
|
|
998
1004
|
_a.sent();
|
|
999
1005
|
return [3 /*break*/, 3];
|
|
@@ -1218,7 +1224,8 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
1218
1224
|
'qb-soap-request-histories',
|
|
1219
1225
|
'qb-soap-request-responses',
|
|
1220
1226
|
'qb-soap-requests',
|
|
1221
|
-
'qb-soap-retries'
|
|
1227
|
+
'qb-soap-retries',
|
|
1228
|
+
this.RESUME_TOKEN_COLLECTION
|
|
1222
1229
|
] } },
|
|
1223
1230
|
{ 'ns.coll': { $not: /.*\.versions$/ } },
|
|
1224
1231
|
{ 'ns.coll': { $not: /^monitor-/ } },
|