@fluidframework/container-loader 2.0.0-dev-rc.5.0.0.271262 → 2.0.0-dev-rc.5.0.0.271717
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/dist/audience.js +1 -2
- package/dist/audience.js.map +1 -1
- package/dist/catchUpMonitor.js +8 -11
- package/dist/catchUpMonitor.js.map +1 -1
- package/dist/connectionManager.js +63 -91
- package/dist/connectionManager.js.map +1 -1
- package/dist/connectionStateHandler.js +11 -35
- package/dist/connectionStateHandler.js.map +1 -1
- package/dist/container.js +122 -155
- package/dist/container.js.map +1 -1
- package/dist/containerContext.js +8 -34
- package/dist/containerContext.js.map +1 -1
- package/dist/containerStorageAdapter.js +9 -17
- package/dist/containerStorageAdapter.js.map +1 -1
- package/dist/debugLogger.js +0 -2
- package/dist/debugLogger.js.map +1 -1
- package/dist/deltaManager.js +35 -48
- package/dist/deltaManager.js.map +1 -1
- package/dist/deltaQueue.js +7 -14
- package/dist/deltaQueue.js.map +1 -1
- package/dist/error.js +4 -5
- package/dist/error.js.map +1 -1
- package/dist/loader.js +1 -5
- package/dist/loader.js.map +1 -1
- package/dist/noopHeuristic.js +1 -3
- package/dist/noopHeuristic.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/protocol/protocol.js +0 -3
- package/dist/protocol/protocol.js.map +1 -1
- package/dist/protocol/quorum.js +9 -30
- package/dist/protocol/quorum.js.map +1 -1
- package/dist/protocol.js +0 -2
- package/dist/protocol.js.map +1 -1
- package/dist/protocolTreeDocumentStorageService.js +0 -10
- package/dist/protocolTreeDocumentStorageService.js.map +1 -1
- package/dist/retriableDocumentStorageService.js +1 -4
- package/dist/retriableDocumentStorageService.js.map +1 -1
- package/dist/serializedStateManager.js +2 -11
- package/dist/serializedStateManager.js.map +1 -1
- package/lib/audience.js +1 -2
- package/lib/audience.js.map +1 -1
- package/lib/catchUpMonitor.js +8 -11
- package/lib/catchUpMonitor.js.map +1 -1
- package/lib/connectionManager.js +63 -91
- package/lib/connectionManager.js.map +1 -1
- package/lib/connectionStateHandler.js +11 -35
- package/lib/connectionStateHandler.js.map +1 -1
- package/lib/container.js +122 -155
- package/lib/container.js.map +1 -1
- package/lib/containerContext.js +8 -34
- package/lib/containerContext.js.map +1 -1
- package/lib/containerStorageAdapter.js +9 -17
- package/lib/containerStorageAdapter.js.map +1 -1
- package/lib/debugLogger.js +0 -2
- package/lib/debugLogger.js.map +1 -1
- package/lib/deltaManager.js +35 -48
- package/lib/deltaManager.js.map +1 -1
- package/lib/deltaQueue.js +7 -14
- package/lib/deltaQueue.js.map +1 -1
- package/lib/error.js +4 -5
- package/lib/error.js.map +1 -1
- package/lib/loader.js +1 -5
- package/lib/loader.js.map +1 -1
- package/lib/noopHeuristic.js +1 -3
- package/lib/noopHeuristic.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/protocol/protocol.js +0 -3
- package/lib/protocol/protocol.js.map +1 -1
- package/lib/protocol/quorum.js +9 -30
- package/lib/protocol/quorum.js.map +1 -1
- package/lib/protocol.js +0 -2
- package/lib/protocol.js.map +1 -1
- package/lib/protocolTreeDocumentStorageService.js +0 -10
- package/lib/protocolTreeDocumentStorageService.js.map +1 -1
- package/lib/retriableDocumentStorageService.js +1 -4
- package/lib/retriableDocumentStorageService.js.map +1 -1
- package/lib/serializedStateManager.js +2 -11
- package/lib/serializedStateManager.js.map +1 -1
- package/package.json +11 -11
- package/src/packageVersion.ts +1 -1
package/dist/audience.js
CHANGED
|
@@ -11,10 +11,9 @@ const internal_1 = require("@fluidframework/core-utils/internal");
|
|
|
11
11
|
* Audience represents all clients connected to the op stream.
|
|
12
12
|
*/
|
|
13
13
|
class Audience extends client_utils_1.TypedEventEmitter {
|
|
14
|
-
members = new Map();
|
|
15
|
-
_currentClientId;
|
|
16
14
|
constructor() {
|
|
17
15
|
super();
|
|
16
|
+
this.members = new Map();
|
|
18
17
|
// We are expecting this class to have many listeners, so we suppress noisy "MaxListenersExceededWarning" logging.
|
|
19
18
|
super.setMaxListeners(0);
|
|
20
19
|
}
|
package/dist/audience.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audience.js","sourceRoot":"","sources":["../src/audience.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAiE;AAGjE,kEAA6D;AAG7D;;GAEG;AACH,MAAa,QAAS,SAAQ,gCAAkC;
|
|
1
|
+
{"version":3,"file":"audience.js","sourceRoot":"","sources":["../src/audience.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAiE;AAGjE,kEAA6D;AAG7D;;GAEG;AACH,MAAa,QAAS,SAAQ,gCAAkC;IAI/D;QACC,KAAK,EAAE,CAAC;QAJQ,YAAO,GAAG,IAAI,GAAG,EAAmB,CAAC;QAKrD,kHAAkH;QAClH,KAAK,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;IAC1B,CAAC;IAEM,OAAO;QACb,OAAO,IAAI,CAAC,gBAAgB,KAAK,SAAS;YACzC,CAAC,CAAC,SAAS;YACX,CAAC,CAAC;gBACA,QAAQ,EAAE,IAAI,CAAC,gBAAgB;gBAC/B,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,gBAAgB,CAAC;aAC5C,CAAC;IACN,CAAC;IAEM,kBAAkB,CAAC,QAAgB;QACzC,IAAI,IAAI,CAAC,gBAAgB,KAAK,QAAQ,EAAE,CAAC;YACxC,MAAM,KAAK,GAAG,IAAI,CAAC,gBAAgB,CAAC;YACpC,IAAI,CAAC,gBAAgB,GAAG,QAAQ,CAAC;YACjC,0EAA0E;YAC1E,yEAAyE;YACzE,qGAAqG;YACrG,IAAI,CAAC,IAAI,CACR,aAAa,EACb,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAkB,CAAC,EACvE,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAkB,CAC9D,CAAC;QACH,CAAC;IACF,CAAC;IAED;;OAEG;IACI,SAAS,CAAC,QAAgB,EAAE,OAAgB;QAClD,mGAAmG;QACnG,+FAA+F;QAC/F,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;YAChC,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;YAC1C,IAAA,iBAAM,EACL,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAClD,KAAK,CAAC,wDAAwD,CAC9D,CAAC;QACH,CAAC;aAAM,CAAC;YACP,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;YACpC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;QAC3C,CAAC;IACF,CAAC;IAED;;;OAGG;IACI,YAAY,CAAC,QAAgB;QACnC,MAAM,aAAa,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QACjD,IAAI,aAAa,KAAK,SAAS,EAAE,CAAC;YACjC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YAC9B,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,QAAQ,EAAE,aAAa,CAAC,CAAC;YACnD,OAAO,IAAI,CAAC;QACb,CAAC;aAAM,CAAC;YACP,OAAO,KAAK,CAAC;QACd,CAAC;IACF,CAAC;IAED;;;;;OAKG;IACI,UAAU;QAChB,OAAO,IAAI,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC9B,CAAC;IAED;;;;;OAKG;IACI,SAAS,CAAC,QAAgB;QAChC,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACnC,CAAC;CACD;AAtFD,4BAsFC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { TypedEventEmitter } from \"@fluid-internal/client-utils\";\nimport { IAudienceEvents, ISelf } from \"@fluidframework/container-definitions\";\nimport { IAudienceOwner } from \"@fluidframework/container-definitions/internal\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { IClient } from \"@fluidframework/driver-definitions\";\n\n/**\n * Audience represents all clients connected to the op stream.\n */\nexport class Audience extends TypedEventEmitter<IAudienceEvents> implements IAudienceOwner {\n\tprivate readonly members = new Map<string, IClient>();\n\tprivate _currentClientId: string | undefined;\n\n\tconstructor() {\n\t\tsuper();\n\t\t// We are expecting this class to have many listeners, so we suppress noisy \"MaxListenersExceededWarning\" logging.\n\t\tsuper.setMaxListeners(0);\n\t}\n\n\tpublic getSelf(): ISelf | undefined {\n\t\treturn this._currentClientId === undefined\n\t\t\t? undefined\n\t\t\t: {\n\t\t\t\t\tclientId: this._currentClientId,\n\t\t\t\t\tclient: this.getMember(this._currentClientId),\n\t\t\t };\n\t}\n\n\tpublic setCurrentClientId(clientId: string): void {\n\t\tif (this._currentClientId !== clientId) {\n\t\t\tconst oldId = this._currentClientId;\n\t\t\tthis._currentClientId = clientId;\n\t\t\t// this.getMember(clientId) could resolve to undefined in these two cases:\n\t\t\t// 1) Feature gates controlling ConnectionStateHandler() behavior are off\n\t\t\t// 2) we are loading from stashed state and audience is empty, but we remember and set prior clientId\n\t\t\tthis.emit(\n\t\t\t\t\"selfChanged\",\n\t\t\t\toldId === undefined ? undefined : ({ clientId: oldId } satisfies ISelf),\n\t\t\t\t{ clientId, client: this.getMember(clientId) } satisfies ISelf,\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Adds a new client to the audience\n\t */\n\tpublic addMember(clientId: string, details: IClient) {\n\t\t// Given that signal delivery is unreliable process, we might observe same client being added twice\n\t\t// In such case we should see exactly same payload (IClient), and should not raise event twice!\n\t\tif (this.members.has(clientId)) {\n\t\t\tconst client = this.members.get(clientId);\n\t\t\tassert(\n\t\t\t\tJSON.stringify(client) === JSON.stringify(details),\n\t\t\t\t0x4b2 /* new client has different payload from existing one */,\n\t\t\t);\n\t\t} else {\n\t\t\tthis.members.set(clientId, details);\n\t\t\tthis.emit(\"addMember\", clientId, details);\n\t\t}\n\t}\n\n\t/**\n\t * Removes a client from the audience. Only emits an event if a client is actually removed\n\t * @returns if a client was removed from the audience\n\t */\n\tpublic removeMember(clientId: string): boolean {\n\t\tconst removedClient = this.members.get(clientId);\n\t\tif (removedClient !== undefined) {\n\t\t\tthis.members.delete(clientId);\n\t\t\tthis.emit(\"removeMember\", clientId, removedClient);\n\t\t\treturn true;\n\t\t} else {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t/**\n\t * Retrieves all the members in the audience.\n\t *\n\t * @remarks When the container is disconnected, this will keep returning the audience as it was last seen before the\n\t * container disconnected.\n\t */\n\tpublic getMembers(): Map<string, IClient> {\n\t\treturn new Map(this.members);\n\t}\n\n\t/**\n\t * Retrieves a specific member of the audience.\n\t *\n\t * @remarks When the container is disconnected, this will keep returning members from the audience as it was last seen\n\t * before the container disconnected.\n\t */\n\tpublic getMember(clientId: string): IClient | undefined {\n\t\treturn this.members.get(clientId);\n\t}\n}\n"]}
|
package/dist/catchUpMonitor.js
CHANGED
|
@@ -11,29 +11,26 @@ const internal_1 = require("@fluidframework/core-utils/internal");
|
|
|
11
11
|
* that were known at the time the monitor was created.
|
|
12
12
|
*/
|
|
13
13
|
class CatchUpMonitor {
|
|
14
|
-
deltaManager;
|
|
15
|
-
listener;
|
|
16
|
-
targetSeqNumber;
|
|
17
|
-
caughtUp = false;
|
|
18
|
-
opHandler = (message) => {
|
|
19
|
-
if (!this.caughtUp && message.sequenceNumber >= this.targetSeqNumber) {
|
|
20
|
-
this.caughtUp = true;
|
|
21
|
-
this.listener();
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
14
|
/**
|
|
25
15
|
* Create the CatchUpMonitor, setting the target sequence number to wait for based on DeltaManager's current state.
|
|
26
16
|
*/
|
|
27
17
|
constructor(deltaManager, listener) {
|
|
28
18
|
this.deltaManager = deltaManager;
|
|
29
19
|
this.listener = listener;
|
|
20
|
+
this.caughtUp = false;
|
|
21
|
+
this.opHandler = (message) => {
|
|
22
|
+
if (!this.caughtUp && message.sequenceNumber >= this.targetSeqNumber) {
|
|
23
|
+
this.caughtUp = true;
|
|
24
|
+
this.listener();
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
this.disposed = false;
|
|
30
28
|
this.targetSeqNumber = this.deltaManager.lastKnownSeqNumber;
|
|
31
29
|
(0, internal_1.assert)(this.targetSeqNumber >= this.deltaManager.lastSequenceNumber, 0x37c /* Cannot wait for seqNumber below last processed sequence number */);
|
|
32
30
|
this.deltaManager.on("op", this.opHandler);
|
|
33
31
|
// Simulate the last processed op to set caughtUp in case we already are
|
|
34
32
|
this.opHandler({ sequenceNumber: this.deltaManager.lastSequenceNumber });
|
|
35
33
|
}
|
|
36
|
-
disposed = false;
|
|
37
34
|
dispose() {
|
|
38
35
|
if (this.disposed) {
|
|
39
36
|
return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"catchUpMonitor.js","sourceRoot":"","sources":["../src/catchUpMonitor.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH,kEAA6D;AAS7D;;;GAGG;AACH,MAAa,cAAc;
|
|
1
|
+
{"version":3,"file":"catchUpMonitor.js","sourceRoot":"","sources":["../src/catchUpMonitor.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH,kEAA6D;AAS7D;;;GAGG;AACH,MAAa,cAAc;IAW1B;;OAEG;IACH,YACkB,YAAqC,EACrC,QAA0B;QAD1B,iBAAY,GAAZ,YAAY,CAAyB;QACrC,aAAQ,GAAR,QAAQ,CAAkB;QAdpC,aAAQ,GAAY,KAAK,CAAC;QAEjB,cAAS,GAAG,CAAC,OAA0D,EAAE,EAAE;YAC3F,IAAI,CAAC,IAAI,CAAC,QAAQ,IAAI,OAAO,CAAC,cAAc,IAAI,IAAI,CAAC,eAAe,EAAE,CAAC;gBACtE,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;gBACrB,IAAI,CAAC,QAAQ,EAAE,CAAC;YACjB,CAAC;QACF,CAAC,CAAC;QAsBK,aAAQ,GAAY,KAAK,CAAC;QAbhC,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,YAAY,CAAC,kBAAkB,CAAC;QAE5D,IAAA,iBAAM,EACL,IAAI,CAAC,eAAe,IAAI,IAAI,CAAC,YAAY,CAAC,kBAAkB,EAC5D,KAAK,CAAC,oEAAoE,CAC1E,CAAC;QAEF,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;QAE3C,wEAAwE;QACxE,IAAI,CAAC,SAAS,CAAC,EAAE,cAAc,EAAE,IAAI,CAAC,YAAY,CAAC,kBAAkB,EAAE,CAAC,CAAC;IAC1E,CAAC;IAGM,OAAO;QACb,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YACnB,OAAO;QACR,CAAC;QACD,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QAErB,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;IAC7C,CAAC;CACD;AAxCD,wCAwCC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IDeltaManager } from \"@fluidframework/container-definitions/internal\";\nimport { IDisposable } from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/driver-definitions/internal\";\n\n/** @see CatchUpMonitor for usage */\ntype CaughtUpListener = () => void;\n\n/** Monitor that emits an event when a Container has caught up to a given point in the op stream */\nexport type ICatchUpMonitor = IDisposable;\n\n/**\n * Monitors a Container's DeltaManager, notifying listeners when all ops have been processed\n * that were known at the time the monitor was created.\n */\nexport class CatchUpMonitor implements ICatchUpMonitor {\n\tprivate readonly targetSeqNumber: number;\n\tprivate caughtUp: boolean = false;\n\n\tprivate readonly opHandler = (message: Pick<ISequencedDocumentMessage, \"sequenceNumber\">) => {\n\t\tif (!this.caughtUp && message.sequenceNumber >= this.targetSeqNumber) {\n\t\t\tthis.caughtUp = true;\n\t\t\tthis.listener();\n\t\t}\n\t};\n\n\t/**\n\t * Create the CatchUpMonitor, setting the target sequence number to wait for based on DeltaManager's current state.\n\t */\n\tconstructor(\n\t\tprivate readonly deltaManager: IDeltaManager<any, any>,\n\t\tprivate readonly listener: CaughtUpListener,\n\t) {\n\t\tthis.targetSeqNumber = this.deltaManager.lastKnownSeqNumber;\n\n\t\tassert(\n\t\t\tthis.targetSeqNumber >= this.deltaManager.lastSequenceNumber,\n\t\t\t0x37c /* Cannot wait for seqNumber below last processed sequence number */,\n\t\t);\n\n\t\tthis.deltaManager.on(\"op\", this.opHandler);\n\n\t\t// Simulate the last processed op to set caughtUp in case we already are\n\t\tthis.opHandler({ sequenceNumber: this.deltaManager.lastSequenceNumber });\n\t}\n\n\tpublic disposed: boolean = false;\n\tpublic dispose() {\n\t\tif (this.disposed) {\n\t\t\treturn;\n\t\t}\n\t\tthis.disposed = true;\n\n\t\tthis.deltaManager.off(\"op\", this.opHandler);\n\t}\n}\n"]}
|
|
@@ -38,26 +38,6 @@ const clientNoDeltaStream = {
|
|
|
38
38
|
};
|
|
39
39
|
const clientIdNoDeltaStream = "storage-only client";
|
|
40
40
|
class NoDeltaStream extends client_utils_1.TypedEventEmitter {
|
|
41
|
-
storageOnlyReason;
|
|
42
|
-
readonlyConnectionReason;
|
|
43
|
-
clientId = clientIdNoDeltaStream;
|
|
44
|
-
claims = {
|
|
45
|
-
scopes: [internal_2.ScopeType.DocRead],
|
|
46
|
-
};
|
|
47
|
-
mode = "read";
|
|
48
|
-
existing = true;
|
|
49
|
-
maxMessageSize = 0;
|
|
50
|
-
version = "";
|
|
51
|
-
initialMessages = [];
|
|
52
|
-
initialSignals = [];
|
|
53
|
-
initialClients = [
|
|
54
|
-
{ client: clientNoDeltaStream, clientId: clientIdNoDeltaStream },
|
|
55
|
-
];
|
|
56
|
-
serviceConfiguration = {
|
|
57
|
-
maxMessageSize: 0,
|
|
58
|
-
blockSize: 0,
|
|
59
|
-
};
|
|
60
|
-
checkpointSequenceNumber = undefined;
|
|
61
41
|
/**
|
|
62
42
|
* Connection which is not connected to socket.
|
|
63
43
|
* @param storageOnlyReason - Reason on why the connection to delta stream is not allowed.
|
|
@@ -67,6 +47,25 @@ class NoDeltaStream extends client_utils_1.TypedEventEmitter {
|
|
|
67
47
|
super();
|
|
68
48
|
this.storageOnlyReason = storageOnlyReason;
|
|
69
49
|
this.readonlyConnectionReason = readonlyConnectionReason;
|
|
50
|
+
this.clientId = clientIdNoDeltaStream;
|
|
51
|
+
this.claims = {
|
|
52
|
+
scopes: [internal_2.ScopeType.DocRead],
|
|
53
|
+
};
|
|
54
|
+
this.mode = "read";
|
|
55
|
+
this.existing = true;
|
|
56
|
+
this.maxMessageSize = 0;
|
|
57
|
+
this.version = "";
|
|
58
|
+
this.initialMessages = [];
|
|
59
|
+
this.initialSignals = [];
|
|
60
|
+
this.initialClients = [
|
|
61
|
+
{ client: clientNoDeltaStream, clientId: clientIdNoDeltaStream },
|
|
62
|
+
];
|
|
63
|
+
this.serviceConfiguration = {
|
|
64
|
+
maxMessageSize: 0,
|
|
65
|
+
blockSize: 0,
|
|
66
|
+
};
|
|
67
|
+
this.checkpointSequenceNumber = undefined;
|
|
68
|
+
this._disposed = false;
|
|
70
69
|
}
|
|
71
70
|
submit(messages) {
|
|
72
71
|
this.emit("nack", this.clientId, messages.map((operation) => {
|
|
@@ -82,7 +81,6 @@ class NoDeltaStream extends client_utils_1.TypedEventEmitter {
|
|
|
82
81
|
content: { message: "Cannot submit signal with storage-only connection", code: 403 },
|
|
83
82
|
});
|
|
84
83
|
}
|
|
85
|
-
_disposed = false;
|
|
86
84
|
get disposed() {
|
|
87
85
|
return this._disposed;
|
|
88
86
|
}
|
|
@@ -111,47 +109,9 @@ const waitForOnline = async () => {
|
|
|
111
109
|
* Exposes various controls to influence this process, including manual reconnects, forced read-only mode, etc.
|
|
112
110
|
*/
|
|
113
111
|
class ConnectionManager {
|
|
114
|
-
serviceProvider;
|
|
115
|
-
containerDirty;
|
|
116
|
-
client;
|
|
117
|
-
logger;
|
|
118
|
-
props;
|
|
119
|
-
/** Connection mode used when reconnecting on error or disconnect. */
|
|
120
|
-
defaultReconnectionMode;
|
|
121
|
-
/**
|
|
122
|
-
* Tracks the current in-progress connection attempt. Undefined if there is none.
|
|
123
|
-
* Note: Once the connection attempt fires and the code becomes asynchronous, its possible that a new connection
|
|
124
|
-
* attempt was fired and this.pendingConnection was overwritten to reflect the new attempt.
|
|
125
|
-
*/
|
|
126
|
-
pendingConnection;
|
|
127
|
-
connection;
|
|
128
|
-
/** Details about connection. undefined if there is no active connection. */
|
|
129
|
-
_connectionDetails;
|
|
130
|
-
/** file ACL - whether user has only read-only access to a file */
|
|
131
|
-
_readonlyPermissions;
|
|
132
|
-
/** tracks host requiring read-only mode. */
|
|
133
|
-
_forceReadonly = false;
|
|
134
|
-
/**
|
|
135
|
-
* Controls whether the DeltaManager will automatically reconnect to the delta stream after receiving a disconnect.
|
|
136
|
-
*/
|
|
137
|
-
_reconnectMode;
|
|
138
|
-
/** True if there is pending (async) reconnection from "read" to "write" */
|
|
139
|
-
pendingReconnect = false;
|
|
140
|
-
clientSequenceNumber = 0;
|
|
141
|
-
clientSequenceNumberObserved = 0;
|
|
142
|
-
/** Counts the number of non-runtime ops sent by the client which may not be acked. */
|
|
143
|
-
localOpsToIgnore = 0;
|
|
144
|
-
/** track clientId used last time when we sent any ops */
|
|
145
|
-
lastSubmittedClientId;
|
|
146
|
-
connectFirstConnection = true;
|
|
147
|
-
_connectionVerboseProps = {};
|
|
148
|
-
_connectionProps = {};
|
|
149
|
-
_disposed = false;
|
|
150
|
-
_outbound;
|
|
151
112
|
get connectionVerboseProps() {
|
|
152
113
|
return this._connectionVerboseProps;
|
|
153
114
|
}
|
|
154
|
-
clientDetails;
|
|
155
115
|
/**
|
|
156
116
|
* The current connection mode, initially read.
|
|
157
117
|
*/
|
|
@@ -272,6 +232,50 @@ class ConnectionManager {
|
|
|
272
232
|
this.client = client;
|
|
273
233
|
this.logger = logger;
|
|
274
234
|
this.props = props;
|
|
235
|
+
/** tracks host requiring read-only mode. */
|
|
236
|
+
this._forceReadonly = false;
|
|
237
|
+
/** True if there is pending (async) reconnection from "read" to "write" */
|
|
238
|
+
this.pendingReconnect = false;
|
|
239
|
+
this.clientSequenceNumber = 0;
|
|
240
|
+
this.clientSequenceNumberObserved = 0;
|
|
241
|
+
/** Counts the number of non-runtime ops sent by the client which may not be acked. */
|
|
242
|
+
this.localOpsToIgnore = 0;
|
|
243
|
+
this.connectFirstConnection = true;
|
|
244
|
+
this._connectionVerboseProps = {};
|
|
245
|
+
this._connectionProps = {};
|
|
246
|
+
this._disposed = false;
|
|
247
|
+
this.opHandler = (documentId, messagesArg) => {
|
|
248
|
+
const messages = Array.isArray(messagesArg) ? messagesArg : [messagesArg];
|
|
249
|
+
this.props.incomingOpHandler(messages, "opHandler");
|
|
250
|
+
};
|
|
251
|
+
this.signalHandler = (signalsArg) => {
|
|
252
|
+
const signals = Array.isArray(signalsArg) ? signalsArg : [signalsArg];
|
|
253
|
+
this.props.signalHandler(signals);
|
|
254
|
+
};
|
|
255
|
+
// Always connect in write mode after getting nacked.
|
|
256
|
+
this.nackHandler = (documentId, messages) => {
|
|
257
|
+
const message = messages[0];
|
|
258
|
+
if (this._readonlyPermissions === true) {
|
|
259
|
+
this.props.closeHandler((0, internal_3.createWriteError)("writeOnReadOnlyDocument", { driverVersion: undefined }));
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
const reconnectInfo = getNackReconnectInfo(message.content);
|
|
263
|
+
// If the nack indicates we cannot retry, then close the container outright
|
|
264
|
+
if (!reconnectInfo.canRetry) {
|
|
265
|
+
this.props.closeHandler(reconnectInfo);
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
this.reconnectOnError("write", reconnectInfo);
|
|
269
|
+
};
|
|
270
|
+
// Connection mode is always read on disconnect/error unless the system mode was write.
|
|
271
|
+
this.disconnectHandlerInternal = (disconnectReason) => {
|
|
272
|
+
// Note: we might get multiple disconnect calls on same socket, as early disconnect notification
|
|
273
|
+
// ("server_disconnect", ODSP-specific) is mapped to "disconnect"
|
|
274
|
+
this.reconnectOnError(this.defaultReconnectionMode, disconnectReason);
|
|
275
|
+
};
|
|
276
|
+
this.errorHandler = (error) => {
|
|
277
|
+
this.reconnectOnError(this.defaultReconnectionMode, error);
|
|
278
|
+
};
|
|
275
279
|
this.clientDetails = this.client.details;
|
|
276
280
|
this.defaultReconnectionMode = this.client.mode;
|
|
277
281
|
this._reconnectMode = reconnectAllowed ? contracts_js_1.ReconnectMode.Enabled : contracts_js_1.ReconnectMode.Never;
|
|
@@ -880,38 +884,6 @@ class ConnectionManager {
|
|
|
880
884
|
}
|
|
881
885
|
}
|
|
882
886
|
}
|
|
883
|
-
opHandler = (documentId, messagesArg) => {
|
|
884
|
-
const messages = Array.isArray(messagesArg) ? messagesArg : [messagesArg];
|
|
885
|
-
this.props.incomingOpHandler(messages, "opHandler");
|
|
886
|
-
};
|
|
887
|
-
signalHandler = (signalsArg) => {
|
|
888
|
-
const signals = Array.isArray(signalsArg) ? signalsArg : [signalsArg];
|
|
889
|
-
this.props.signalHandler(signals);
|
|
890
|
-
};
|
|
891
|
-
// Always connect in write mode after getting nacked.
|
|
892
|
-
nackHandler = (documentId, messages) => {
|
|
893
|
-
const message = messages[0];
|
|
894
|
-
if (this._readonlyPermissions === true) {
|
|
895
|
-
this.props.closeHandler((0, internal_3.createWriteError)("writeOnReadOnlyDocument", { driverVersion: undefined }));
|
|
896
|
-
return;
|
|
897
|
-
}
|
|
898
|
-
const reconnectInfo = getNackReconnectInfo(message.content);
|
|
899
|
-
// If the nack indicates we cannot retry, then close the container outright
|
|
900
|
-
if (!reconnectInfo.canRetry) {
|
|
901
|
-
this.props.closeHandler(reconnectInfo);
|
|
902
|
-
return;
|
|
903
|
-
}
|
|
904
|
-
this.reconnectOnError("write", reconnectInfo);
|
|
905
|
-
};
|
|
906
|
-
// Connection mode is always read on disconnect/error unless the system mode was write.
|
|
907
|
-
disconnectHandlerInternal = (disconnectReason) => {
|
|
908
|
-
// Note: we might get multiple disconnect calls on same socket, as early disconnect notification
|
|
909
|
-
// ("server_disconnect", ODSP-specific) is mapped to "disconnect"
|
|
910
|
-
this.reconnectOnError(this.defaultReconnectionMode, disconnectReason);
|
|
911
|
-
};
|
|
912
|
-
errorHandler = (error) => {
|
|
913
|
-
this.reconnectOnError(this.defaultReconnectionMode, error);
|
|
914
|
-
};
|
|
915
887
|
}
|
|
916
888
|
exports.ConnectionManager = ConnectionManager;
|
|
917
889
|
//# sourceMappingURL=connectionManager.js.map
|