@fluidframework/ordered-collection 2.70.0 → 2.71.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/CHANGELOG.md +4 -0
- package/api-report/ordered-collection.legacy.beta.api.md +2 -0
- package/dist/consensusOrderedCollection.d.ts +5 -0
- package/dist/consensusOrderedCollection.d.ts.map +1 -1
- package/dist/consensusOrderedCollection.js +11 -0
- package/dist/consensusOrderedCollection.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.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/testUtils.d.ts +12 -0
- package/dist/testUtils.d.ts.map +1 -1
- package/dist/testUtils.js +29 -1
- package/dist/testUtils.js.map +1 -1
- package/lib/consensusOrderedCollection.d.ts +5 -0
- package/lib/consensusOrderedCollection.d.ts.map +1 -1
- package/lib/consensusOrderedCollection.js +11 -0
- package/lib/consensusOrderedCollection.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.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/testUtils.d.ts +12 -0
- package/lib/testUtils.d.ts.map +1 -1
- package/lib/testUtils.js +26 -0
- package/lib/testUtils.js.map +1 -1
- package/package.json +17 -17
- package/src/consensusOrderedCollection.ts +15 -0
- package/src/index.ts +6 -1
- package/src/packageVersion.ts +1 -1
- package/src/testUtils.ts +32 -0
package/CHANGELOG.md
CHANGED
|
@@ -28,6 +28,8 @@ export class ConsensusOrderedCollection<T = any> extends SharedObject<IConsensus
|
|
|
28
28
|
protected release(acquireId: string): void;
|
|
29
29
|
// (undocumented)
|
|
30
30
|
protected releaseCore(acquireId: string): void;
|
|
31
|
+
// @sealed
|
|
32
|
+
protected rollback(content: unknown, localOpMetadata: unknown): void;
|
|
31
33
|
// (undocumented)
|
|
32
34
|
protected summarizeCore(serializer: IFluidSerializer): ISummaryTreeWithStats;
|
|
33
35
|
waitAndAcquire(callback: ConsensusCallback<T>): Promise<void>;
|
|
@@ -64,5 +64,10 @@ export declare class ConsensusOrderedCollection<T = any> extends SharedObject<IC
|
|
|
64
64
|
private serializeValue;
|
|
65
65
|
private deserializeValue;
|
|
66
66
|
protected applyStashedOp(): void;
|
|
67
|
+
/**
|
|
68
|
+
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.rollback}
|
|
69
|
+
* @sealed
|
|
70
|
+
*/
|
|
71
|
+
protected rollback(content: unknown, localOpMetadata: unknown): void;
|
|
67
72
|
}
|
|
68
73
|
//# sourceMappingURL=consensusOrderedCollection.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"consensusOrderedCollection.d.ts","sourceRoot":"","sources":["../src/consensusOrderedCollection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EACX,kBAAkB,EAClB,sBAAsB,EACtB,sBAAsB,EACtB,MAAM,gDAAgD,CAAC;AAExD,OAAO,KAAK,EACX,qBAAqB,EACrB,yBAAyB,EAGzB,MAAM,8CAA8C,CAAC;AAEtD,OAAO,EACN,KAAK,gBAAgB,EACrB,YAAY,EACZ,MAAM,6CAA6C,CAAC;AAGrD,OAAO,EACN,KAAK,iBAAiB,EAEtB,KAAK,2BAA2B,EAChC,KAAK,iCAAiC,EACtC,KAAK,kBAAkB,EACvB,MAAM,iBAAiB,CAAC;AAgEzB;;;;;;;;;GASG;AAIH,qBAAa,0BAA0B,CAAC,CAAC,GAAG,GAAG,CAC9C,SAAQ,YAAY,CAAC,iCAAiC,CAAC,CAAC,CAAC,CACzD,YAAW,2BAA2B,CAAC,CAAC,CAAC;IAexC,OAAO,CAAC,QAAQ,CAAC,IAAI;IAbtB;;OAEG;IACH,OAAO,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AIb,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAe1D,SAAS,CAAC,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAS/C,SAAS,CAAC,OAAO,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAiB1C,SAAS,CAAC,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAU9C;;OAEG;cACa,QAAQ,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC;IAsBxE,SAAS,CAAC,YAAY,IAAI,IAAI;IAQ9B;;OAEG;IACH,SAAS,CAAC,mBAAmB,CAAC,kBAAkB,EAAE,yBAAyB,GAAG,IAAI;IAOlF,OAAO,CAAC,cAAc;YA6CR,MAAM;IAepB,OAAO,CAAC,OAAO;IAKf,OAAO,CAAC,WAAW;YAmBL,eAAe;IAY7B,OAAO,CAAC,YAAY;IAepB,OAAO,CAAC,cAAc;IAItB,OAAO,CAAC,gBAAgB;IAIxB,SAAS,CAAC,cAAc,IAAI,IAAI;IAIhC;;;OAGG;IACH,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,OAAO,GAAG,IAAI;CAUpE"}
|
|
@@ -290,6 +290,17 @@ class ConsensusOrderedCollection extends internal_4.SharedObject {
|
|
|
290
290
|
applyStashedOp() {
|
|
291
291
|
throw new Error("not implemented");
|
|
292
292
|
}
|
|
293
|
+
/**
|
|
294
|
+
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.rollback}
|
|
295
|
+
* @sealed
|
|
296
|
+
*/
|
|
297
|
+
rollback(content, localOpMetadata) {
|
|
298
|
+
(0, internal_1.assert)(typeof localOpMetadata === "function", 0xc93 /* localOpMetadata should be a function */);
|
|
299
|
+
// A resolve function is passed as the localOpMetadata on this.submitLocalMessage().
|
|
300
|
+
// On rollback we resolve with undefined and the promises will handle it appropriately.
|
|
301
|
+
const resolve = localOpMetadata;
|
|
302
|
+
resolve(undefined);
|
|
303
|
+
}
|
|
293
304
|
}
|
|
294
305
|
exports.ConsensusOrderedCollection = ConsensusOrderedCollection;
|
|
295
306
|
//# sourceMappingURL=consensusOrderedCollection.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"consensusOrderedCollection.js","sourceRoot":"","sources":["../src/consensusOrderedCollection.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAA8D;AAC9D,kEAA8E;AAM9E,0EAA0E;AAO1E,qEAA4E;AAC5E,0EAGqD;AACrD,+BAAkC;AAElC,mDAMyB;AAEzB,MAAM,oBAAoB,GAAG,QAAQ,CAAC;AACtC,MAAM,wBAAwB,GAAG,aAAa,CAAC;AA2D/C,MAAM,0BAA0B,GAAG,SAAS,CAAC;AAE7C;;;;;;;;;GASG;AAEH,8DAA8D;AAC9D,8DAA8D;AAC9D,MAAa,0BACZ,SAAQ,uBAAkD;IAQ1D;;;OAGG;IACH,YACC,EAAU,EACV,OAA+B,EAC/B,UAA8B,EACb,IAA2B;QAE5C,KAAK,CAAC,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,mCAAmC,CAAC,CAAC;QAFnD,SAAI,GAAJ,IAAI,CAAuB;QAb7C;;WAEG;QACK,gBAAW,GAAuB,IAAI,GAAG,EAAE,CAAC;QAcnD,4FAA4F;QAC5F,qDAAqD;QACrD,oFAAoF;QACpF,iFAAiF;QACjF,OAAO,CAAC,SAAS,EAAE,CAAC,EAAE,CAAC,cAAc,EAAE,CAAC,QAAgB,EAAE,EAAE;YAC3D,IAAA,iBAAM,EAAC,CAAC,CAAC,QAAQ,EAAE,KAAK,CAAC,qCAAqC,CAAC,CAAC;YAChE,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;QAC7B,CAAC,CAAC,CAAC;IACJ,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,GAAG,CAAC,KAAQ;QACxB,MAAM,QAAQ,GAAG,IAAI,CAAC,cAAc,CAA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KAAK,EAAE,UAA4B;QACzD,OAAO,UAAU,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IACjD,CAAC;IAEO,gBAAgB,CAAC,OAAe,EAAE,UAA4B;QACrE,OAAO,UAAU,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAClC,CAAC;IAES,cAAc;QACvB,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACpC,CAAC;CACD;AAzUD,gEAyUC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { bufferToString } from \"@fluid-internal/client-utils\";\nimport { assert, unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport type {\n\tIChannelAttributes,\n\tIFluidDataStoreRuntime,\n\tIChannelStorageService,\n} from \"@fluidframework/datastore-definitions/internal\";\nimport { MessageType } from \"@fluidframework/driver-definitions/internal\";\nimport type {\n\tISummaryTreeWithStats,\n\tIRuntimeMessageCollection,\n\tIRuntimeMessagesContent,\n\tISequencedMessageEnvelope,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport { SummaryTreeBuilder } from \"@fluidframework/runtime-utils/internal\";\nimport {\n\ttype IFluidSerializer,\n\tSharedObject,\n} from \"@fluidframework/shared-object-base/internal\";\nimport { v4 as uuid } from \"uuid\";\n\nimport {\n\ttype ConsensusCallback,\n\tConsensusResult,\n\ttype IConsensusOrderedCollection,\n\ttype IConsensusOrderedCollectionEvents,\n\ttype IOrderedCollection,\n} from \"./interfaces.js\";\n\nconst snapshotFileNameData = \"header\";\nconst snapshotFileNameTracking = \"jobTracking\";\n\ninterface IConsensusOrderedCollectionValue<T> {\n\t// an ID used to indicate acquired item.\n\t// Used in acquire/release/complete ops.\n\treadonly acquireId: string;\n\n\t// The actual value\n\treadonly value: T;\n}\n\n/**\n * An operation for consensus ordered collection\n */\ninterface IConsensusOrderedCollectionAddOperation<T> {\n\topName: \"add\";\n\t// serialized value\n\tvalue: string;\n\tdeserializedValue?: T;\n}\n\ninterface IConsensusOrderedCollectionAcquireOperation {\n\topName: \"acquire\";\n\t// an ID used to indicate acquired item.\n\t// Used in acquire/release/complete ops.\n\tacquireId: string;\n}\n\ninterface IConsensusOrderedCollectionCompleteOperation {\n\topName: \"complete\";\n\t// an ID used to indicate acquired item.\n\t// Used in acquire/release/complete ops.\n\tacquireId: string;\n}\n\ninterface IConsensusOrderedCollectionReleaseOperation {\n\topName: \"release\";\n\t// an ID used to indicate acquired item.\n\t// Used in acquire/release/complete ops.\n\tacquireId: string;\n}\n\ntype IConsensusOrderedCollectionOperation<T> =\n\t| IConsensusOrderedCollectionAddOperation<T>\n\t| IConsensusOrderedCollectionAcquireOperation\n\t| IConsensusOrderedCollectionCompleteOperation\n\t| IConsensusOrderedCollectionReleaseOperation;\n\n/**\n * The type of the resolve function to call after the local operation is acknowledged.\n */\ntype PendingResolve<T> = (value: IConsensusOrderedCollectionValue<T> | undefined) => void;\n\n/**\n * For job tracking, we need to keep track of which client \"owns\" a given value.\n * Key is the acquireId from when it was acquired\n * Value is the acquired value, and the id of the client who acquired it, or undefined for unattached client\n */\ntype JobTrackingInfo<T> = Map<string, { value: T; clientId: string | undefined }>;\nconst idForLocalUnattachedClient = undefined;\n\n/**\n * Implementation of a consensus collection shared object\n *\n * Implements the shared object's communication, and the semantics around the\n * release/complete mechanism following acquire.\n *\n * Generally not used directly. A derived type will pass in a backing data type\n * IOrderedCollection that will define the deterministic add/acquire order and snapshot ability.\n * @legacy @beta\n */\n\n// TODO: #22835 Use undefined instead of any (breaking change)\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport class ConsensusOrderedCollection<T = any>\n\textends SharedObject<IConsensusOrderedCollectionEvents<T>>\n\timplements IConsensusOrderedCollection<T>\n{\n\t/**\n\t * The set of values that have been acquired but not yet completed or released\n\t */\n\tprivate jobTracking: JobTrackingInfo<T> = new Map();\n\n\t/**\n\t * Constructs a new consensus collection. If the object is non-local an id and service interfaces will\n\t * be provided\n\t */\n\tprotected constructor(\n\t\tid: string,\n\t\truntime: IFluidDataStoreRuntime,\n\t\tattributes: IChannelAttributes,\n\t\tprivate readonly data: IOrderedCollection<T>,\n\t) {\n\t\tsuper(id, runtime, attributes, \"fluid_consensusOrderedCollection_\");\n\n\t\t// We can't simply call this.removeClient(this.runtime.clientId) in on runtime disconnected,\n\t\t// because other clients may disconnect concurrently.\n\t\t// Disconnect order matters because it defines the order items go back to the queue.\n\t\t// So we put items back to queue only when we process our own removeMember event.\n\t\truntime.getQuorum().on(\"removeMember\", (clientId: string) => {\n\t\t\tassert(!!clientId, 0x067 /* \"Missing clientId for removal!\" */);\n\t\t\tthis.removeClient(clientId);\n\t\t});\n\t}\n\n\t/**\n\t * Add a value to the consensus collection.\n\t */\n\tpublic async add(value: T): Promise<void> {\n\t\tconst valueSer = this.serializeValue(value, this.serializer);\n\n\t\tif (!this.isAttached()) {\n\t\t\t// For the case where this is not attached yet, explicitly JSON\n\t\t\t// clone the value to match the behavior of going thru the wire.\n\t\t\tconst addValue = this.deserializeValue(valueSer, this.serializer) as T;\n\t\t\tthis.addCore(addValue);\n\t\t\treturn;\n\t\t}\n\n\t\tawait this.submit<IConsensusOrderedCollectionAddOperation<T>>({\n\t\t\topName: \"add\",\n\t\t\tvalue: valueSer,\n\t\t\tdeserializedValue: value,\n\t\t});\n\t}\n\n\t/**\n\t * Remove a value from the consensus collection. If the collection is empty, returns false.\n\t * Otherwise calls callback with the value\n\t */\n\tpublic async acquire(callback: ConsensusCallback<T>): Promise<boolean> {\n\t\tconst result = await this.acquireInternal();\n\t\tif (result === undefined) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst res = await callback(result.value);\n\n\t\tswitch (res) {\n\t\t\tcase ConsensusResult.Complete: {\n\t\t\t\tawait this.complete(result.acquireId);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase ConsensusResult.Release: {\n\t\t\t\tthis.release(result.acquireId);\n\t\t\t\tthis.emit(\"localRelease\", result.value, true /* intentional */);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tunreachableCase(res);\n\t\t\t}\n\t\t}\n\n\t\treturn true;\n\t}\n\n\t/**\n\t * Wait for a value to be available and acquire it from the consensus collection\n\t */\n\tpublic async waitAndAcquire(callback: ConsensusCallback<T>): Promise<void> {\n\t\tdo {\n\t\t\tif (this.data.size() === 0) {\n\t\t\t\t// Wait for new entry before trying to acquire again\n\t\t\t\tawait this.newAckBasedPromise<T>((resolve) => {\n\t\t\t\t\tthis.once(\"add\", resolve);\n\t\t\t\t});\n\t\t\t}\n\t\t} while (!(await this.acquire(callback)));\n\t}\n\n\tprotected summarizeCore(serializer: IFluidSerializer): ISummaryTreeWithStats {\n\t\t// If we are transitioning from unattached to attached mode,\n\t\t// then we are losing all checked out work!\n\t\tthis.removeClient(idForLocalUnattachedClient);\n\n\t\tconst builder = new SummaryTreeBuilder();\n\t\tlet blobContent = this.serializeValue(this.data.asArray(), serializer);\n\t\tbuilder.addBlob(snapshotFileNameData, blobContent);\n\t\tblobContent = this.serializeValue([...this.jobTracking.entries()], serializer);\n\t\tbuilder.addBlob(snapshotFileNameTracking, blobContent);\n\t\treturn builder.getSummaryTree();\n\t}\n\n\tprotected isActive(): boolean {\n\t\treturn this.runtime.connected && this.deltaManager.active;\n\t}\n\n\tprotected async complete(acquireId: string): Promise<void> {\n\t\tif (!this.isAttached()) {\n\t\t\tthis.completeCore(acquireId);\n\t\t\treturn;\n\t\t}\n\n\t\t// if not active, this item already was released to queue (as observed by other clients)\n\t\tif (this.isActive()) {\n\t\t\tawait this.submit<IConsensusOrderedCollectionCompleteOperation>({\n\t\t\t\topName: \"complete\",\n\t\t\t\tacquireId,\n\t\t\t});\n\t\t}\n\t}\n\n\tprotected completeCore(acquireId: string): void {\n\t\t// Note: item may be no longer in jobTracking and returned back to queue!\n\t\tconst rec = this.jobTracking.get(acquireId);\n\t\tif (rec !== undefined) {\n\t\t\tthis.jobTracking.delete(acquireId);\n\t\t\tthis.emit(\"complete\", rec.value);\n\t\t}\n\t}\n\n\tprotected release(acquireId: string): void {\n\t\tif (!this.isAttached()) {\n\t\t\tthis.releaseCore(acquireId);\n\t\t\treturn;\n\t\t}\n\n\t\t// if not active, this item already was released to queue (as observed by other clients)\n\t\tif (this.isActive()) {\n\t\t\tthis.submit<IConsensusOrderedCollectionReleaseOperation>({\n\t\t\t\topName: \"release\",\n\t\t\t\tacquireId,\n\t\t\t}).catch((error) => {\n\t\t\t\tthis.logger.sendErrorEvent({ eventName: \"ConsensusQueue_release\" }, error);\n\t\t\t});\n\t\t}\n\t}\n\n\tprotected releaseCore(acquireId: string): void {\n\t\t// Note: item may be no longer in jobTracking and returned back to queue!\n\t\tconst rec = this.jobTracking.get(acquireId);\n\t\tif (rec !== undefined) {\n\t\t\tthis.jobTracking.delete(acquireId);\n\t\t\tthis.data.add(rec.value);\n\t\t\tthis.emit(\"add\", rec.value, false /* newlyAdded */);\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}\n\t */\n\tprotected async loadCore(storage: IChannelStorageService): Promise<void> {\n\t\tassert(\n\t\t\tthis.jobTracking.size === 0,\n\t\t\t0x068 /* \"On consensusOrderedCollection load, job tracking size > 0\" */,\n\t\t);\n\t\tconst blob = await storage.readBlob(snapshotFileNameTracking);\n\t\tconst rawContentTracking = bufferToString(blob, \"utf8\");\n\t\tconst content = this.deserializeValue(rawContentTracking, this.serializer);\n\t\tthis.jobTracking = new Map(\n\t\t\tcontent as Iterable<[string, { value: T; clientId: string | undefined }]>,\n\t\t);\n\n\t\tassert(\n\t\t\tthis.data.size() === 0,\n\t\t\t0x069 /* \"On consensusOrderedCollection load, data size > 0\" */,\n\t\t);\n\t\tconst blob2 = await storage.readBlob(snapshotFileNameData);\n\t\tconst rawContentData = bufferToString(blob2, \"utf8\");\n\t\tconst content2 = this.deserializeValue(rawContentData, this.serializer) as T[];\n\t\tthis.data.loadFrom(content2);\n\t}\n\n\tprotected onDisconnect(): void {\n\t\tfor (const [, { value, clientId }] of this.jobTracking) {\n\t\t\tif (clientId === this.runtime.clientId) {\n\t\t\t\tthis.emit(\"localRelease\", value, false /* intentional */);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.processMessagesCore}\n\t */\n\tprotected processMessagesCore(messagesCollection: IRuntimeMessageCollection): void {\n\t\tconst { envelope, local, messagesContent } = messagesCollection;\n\t\tfor (const messageContent of messagesContent) {\n\t\t\tthis.processMessage(envelope, messageContent, local);\n\t\t}\n\t}\n\n\tprivate processMessage(\n\t\tmessageEnvelope: ISequencedMessageEnvelope,\n\t\tmessageContent: IRuntimeMessagesContent,\n\t\tlocal: boolean,\n\t): void {\n\t\tif (messageEnvelope.type === MessageType.Operation) {\n\t\t\tconst op = messageContent.contents as IConsensusOrderedCollectionOperation<T>;\n\t\t\tlet value: IConsensusOrderedCollectionValue<T> | undefined;\n\t\t\tswitch (op.opName) {\n\t\t\t\tcase \"add\": {\n\t\t\t\t\tif (op.deserializedValue === undefined) {\n\t\t\t\t\t\tthis.addCore(this.deserializeValue(op.value, this.serializer) as T);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.addCore(op.deserializedValue);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase \"acquire\": {\n\t\t\t\t\tvalue = this.acquireCore(op.acquireId, messageEnvelope.clientId ?? undefined);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase \"complete\": {\n\t\t\t\t\tthis.completeCore(op.acquireId);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase \"release\": {\n\t\t\t\t\tthis.releaseCore(op.acquireId);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tdefault: {\n\t\t\t\t\tunreachableCase(op);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (local) {\n\t\t\t\t// Resolve the pending promise for this operation now that we have received an ack for it.\n\t\t\t\tconst resolve = messageContent.localOpMetadata as PendingResolve<T>;\n\t\t\t\tresolve(value);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate async submit<TMessage extends IConsensusOrderedCollectionOperation<T>>(\n\t\tmessage: TMessage,\n\t): Promise<IConsensusOrderedCollectionValue<T> | undefined> {\n\t\tassert(this.isAttached(), 0x06a /* \"Trying to submit message while detached!\" */);\n\n\t\treturn this.newAckBasedPromise<IConsensusOrderedCollectionValue<T> | undefined>(\n\t\t\t(resolve) => {\n\t\t\t\t// Send the resolve function as the localOpMetadata. This will be provided back to us when the\n\t\t\t\t// op is ack'd.\n\t\t\t\tthis.submitLocalMessage(message, resolve);\n\t\t\t\t// If we fail due to runtime being disposed, it's better to return undefined then unhandled exception.\n\t\t\t},\n\t\t).catch((error) => undefined);\n\t}\n\n\tprivate addCore(value: T): void {\n\t\tthis.data.add(value);\n\t\tthis.emit(\"add\", value, true /* newlyAdded */);\n\t}\n\n\tprivate acquireCore(\n\t\tacquireId: string,\n\t\tclientId?: string,\n\t): IConsensusOrderedCollectionValue<T> | undefined {\n\t\tif (this.data.size() === 0) {\n\t\t\treturn undefined;\n\t\t}\n\t\tconst value = this.data.remove();\n\n\t\tconst value2: IConsensusOrderedCollectionValue<T> = {\n\t\t\tacquireId,\n\t\t\tvalue,\n\t\t};\n\t\tthis.jobTracking.set(value2.acquireId, { value, clientId });\n\n\t\tthis.emit(\"acquire\", value, clientId);\n\t\treturn value2;\n\t}\n\n\tprivate async acquireInternal(): Promise<IConsensusOrderedCollectionValue<T> | undefined> {\n\t\tif (!this.isAttached()) {\n\t\t\t// can be undefined if queue is empty\n\t\t\treturn this.acquireCore(uuid(), idForLocalUnattachedClient);\n\t\t}\n\n\t\treturn this.submit<IConsensusOrderedCollectionAcquireOperation>({\n\t\t\topName: \"acquire\",\n\t\t\tacquireId: uuid(),\n\t\t});\n\t}\n\n\tprivate removeClient(clientIdToRemove?: string): void {\n\t\tconst added: T[] = [];\n\t\tfor (const [acquireId, { value, clientId }] of this.jobTracking) {\n\t\t\tif (clientId === clientIdToRemove) {\n\t\t\t\tthis.jobTracking.delete(acquireId);\n\t\t\t\tthis.data.add(value);\n\t\t\t\tadded.push(value);\n\t\t\t}\n\t\t}\n\n\t\t// Raise all events only after all state changes are completed,\n\t\t// to guarantee same ordering of operations if collection is manipulated from events.\n\t\tadded.map((value) => this.emit(\"add\", value, false /* newlyAdded */));\n\t}\n\n\tprivate serializeValue(value, serializer: IFluidSerializer): string {\n\t\treturn serializer.stringify(value, this.handle);\n\t}\n\n\tprivate deserializeValue(content: string, serializer: IFluidSerializer): unknown {\n\t\treturn serializer.parse(content);\n\t}\n\n\tprotected applyStashedOp(): void {\n\t\tthrow new Error(\"not implemented\");\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"consensusOrderedCollection.js","sourceRoot":"","sources":["../src/consensusOrderedCollection.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAA8D;AAC9D,kEAA8E;AAM9E,0EAA0E;AAO1E,qEAA4E;AAC5E,0EAGqD;AACrD,+BAAkC;AAElC,mDAMyB;AAEzB,MAAM,oBAAoB,GAAG,QAAQ,CAAC;AACtC,MAAM,wBAAwB,GAAG,aAAa,CAAC;AA2D/C,MAAM,0BAA0B,GAAG,SAAS,CAAC;AAE7C;;;;;;;;;GASG;AAEH,8DAA8D;AAC9D,8DAA8D;AAC9D,MAAa,0BACZ,SAAQ,uBAAkD;IAQ1D;;;OAGG;IACH,YACC,EAAU,EACV,OAA+B,EAC/B,UAA8B,EACb,IAA2B;QAE5C,KAAK,CAAC,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,mCAAmC,CAAC,CAAC;QAFnD,SAAI,GAAJ,IAAI,CAAuB;QAb7C;;WAEG;QACK,gBAAW,GAAuB,IAAI,GAAG,EAAE,CAAC;QAcnD,4FAA4F;QAC5F,qDAAqD;QACrD,oFAAoF;QACpF,iFAAiF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,CAAC,CAAC;gBACnC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;gBACrB,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACnB,CAAC;QACF,CAAC;QAED,+DAA+D;QAC/D,qFAAqF;QACrF,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,gBAAgB,CAAC,CAAC,CAAC;IACvE,CAAC;IAEO,cAAc,CAAC,KAAK,EAAE,UAA4B;QACzD,OAAO,UAAU,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IACjD,CAAC;IAEO,gBAAgB,CAAC,OAAe,EAAE,UAA4B;QACrE,OAAO,UAAU,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAClC,CAAC;IAES,cAAc;QACvB,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACpC,CAAC;IAED;;;OAGG;IACO,QAAQ,CAAC,OAAgB,EAAE,eAAwB;QAC5D,IAAA,iBAAM,EACL,OAAO,eAAe,KAAK,UAAU,EACrC,KAAK,CAAC,0CAA0C,CAChD,CAAC;QACF,oFAAoF;QACpF,uFAAuF;QACvF,MAAM,OAAO,GAAG,eAAoC,CAAC;QACrD,OAAO,CAAC,SAAS,CAAC,CAAC;IACpB,CAAC;CACD;AAxVD,gEAwVC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { bufferToString } from \"@fluid-internal/client-utils\";\nimport { assert, unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport type {\n\tIChannelAttributes,\n\tIFluidDataStoreRuntime,\n\tIChannelStorageService,\n} from \"@fluidframework/datastore-definitions/internal\";\nimport { MessageType } from \"@fluidframework/driver-definitions/internal\";\nimport type {\n\tISummaryTreeWithStats,\n\tIRuntimeMessageCollection,\n\tIRuntimeMessagesContent,\n\tISequencedMessageEnvelope,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport { SummaryTreeBuilder } from \"@fluidframework/runtime-utils/internal\";\nimport {\n\ttype IFluidSerializer,\n\tSharedObject,\n} from \"@fluidframework/shared-object-base/internal\";\nimport { v4 as uuid } from \"uuid\";\n\nimport {\n\ttype ConsensusCallback,\n\tConsensusResult,\n\ttype IConsensusOrderedCollection,\n\ttype IConsensusOrderedCollectionEvents,\n\ttype IOrderedCollection,\n} from \"./interfaces.js\";\n\nconst snapshotFileNameData = \"header\";\nconst snapshotFileNameTracking = \"jobTracking\";\n\ninterface IConsensusOrderedCollectionValue<T> {\n\t// an ID used to indicate acquired item.\n\t// Used in acquire/release/complete ops.\n\treadonly acquireId: string;\n\n\t// The actual value\n\treadonly value: T;\n}\n\n/**\n * An operation for consensus ordered collection\n */\ninterface IConsensusOrderedCollectionAddOperation<T> {\n\topName: \"add\";\n\t// serialized value\n\tvalue: string;\n\tdeserializedValue?: T;\n}\n\ninterface IConsensusOrderedCollectionAcquireOperation {\n\topName: \"acquire\";\n\t// an ID used to indicate acquired item.\n\t// Used in acquire/release/complete ops.\n\tacquireId: string;\n}\n\ninterface IConsensusOrderedCollectionCompleteOperation {\n\topName: \"complete\";\n\t// an ID used to indicate acquired item.\n\t// Used in acquire/release/complete ops.\n\tacquireId: string;\n}\n\ninterface IConsensusOrderedCollectionReleaseOperation {\n\topName: \"release\";\n\t// an ID used to indicate acquired item.\n\t// Used in acquire/release/complete ops.\n\tacquireId: string;\n}\n\ntype IConsensusOrderedCollectionOperation<T> =\n\t| IConsensusOrderedCollectionAddOperation<T>\n\t| IConsensusOrderedCollectionAcquireOperation\n\t| IConsensusOrderedCollectionCompleteOperation\n\t| IConsensusOrderedCollectionReleaseOperation;\n\n/**\n * The type of the resolve function to call after the local operation is acknowledged.\n */\ntype PendingResolve<T> = (value: IConsensusOrderedCollectionValue<T> | undefined) => void;\n\n/**\n * For job tracking, we need to keep track of which client \"owns\" a given value.\n * Key is the acquireId from when it was acquired\n * Value is the acquired value, and the id of the client who acquired it, or undefined for unattached client\n */\ntype JobTrackingInfo<T> = Map<string, { value: T; clientId: string | undefined }>;\nconst idForLocalUnattachedClient = undefined;\n\n/**\n * Implementation of a consensus collection shared object\n *\n * Implements the shared object's communication, and the semantics around the\n * release/complete mechanism following acquire.\n *\n * Generally not used directly. A derived type will pass in a backing data type\n * IOrderedCollection that will define the deterministic add/acquire order and snapshot ability.\n * @legacy @beta\n */\n\n// TODO: #22835 Use undefined instead of any (breaking change)\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport class ConsensusOrderedCollection<T = any>\n\textends SharedObject<IConsensusOrderedCollectionEvents<T>>\n\timplements IConsensusOrderedCollection<T>\n{\n\t/**\n\t * The set of values that have been acquired but not yet completed or released\n\t */\n\tprivate jobTracking: JobTrackingInfo<T> = new Map();\n\n\t/**\n\t * Constructs a new consensus collection. If the object is non-local an id and service interfaces will\n\t * be provided\n\t */\n\tprotected constructor(\n\t\tid: string,\n\t\truntime: IFluidDataStoreRuntime,\n\t\tattributes: IChannelAttributes,\n\t\tprivate readonly data: IOrderedCollection<T>,\n\t) {\n\t\tsuper(id, runtime, attributes, \"fluid_consensusOrderedCollection_\");\n\n\t\t// We can't simply call this.removeClient(this.runtime.clientId) in on runtime disconnected,\n\t\t// because other clients may disconnect concurrently.\n\t\t// Disconnect order matters because it defines the order items go back to the queue.\n\t\t// So we put items back to queue only when we process our own removeMember event.\n\t\truntime.getQuorum().on(\"removeMember\", (clientId: string) => {\n\t\t\tassert(!!clientId, 0x067 /* \"Missing clientId for removal!\" */);\n\t\t\tthis.removeClient(clientId);\n\t\t});\n\t}\n\n\t/**\n\t * Add a value to the consensus collection.\n\t */\n\tpublic async add(value: T): Promise<void> {\n\t\tconst valueSer = this.serializeValue(value, this.serializer);\n\n\t\tif (!this.isAttached()) {\n\t\t\t// For the case where this is not attached yet, explicitly JSON\n\t\t\t// clone the value to match the behavior of going thru the wire.\n\t\t\tconst addValue = this.deserializeValue(valueSer, this.serializer) as T;\n\t\t\tthis.addCore(addValue);\n\t\t\treturn;\n\t\t}\n\n\t\tawait this.submit<IConsensusOrderedCollectionAddOperation<T>>({\n\t\t\topName: \"add\",\n\t\t\tvalue: valueSer,\n\t\t\tdeserializedValue: value,\n\t\t});\n\t}\n\n\t/**\n\t * Remove a value from the consensus collection. If the collection is empty, returns false.\n\t * Otherwise calls callback with the value\n\t */\n\tpublic async acquire(callback: ConsensusCallback<T>): Promise<boolean> {\n\t\tconst result = await this.acquireInternal();\n\t\tif (result === undefined) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst res = await callback(result.value);\n\n\t\tswitch (res) {\n\t\t\tcase ConsensusResult.Complete: {\n\t\t\t\tawait this.complete(result.acquireId);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase ConsensusResult.Release: {\n\t\t\t\tthis.release(result.acquireId);\n\t\t\t\tthis.emit(\"localRelease\", result.value, true /* intentional */);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tunreachableCase(res);\n\t\t\t}\n\t\t}\n\n\t\treturn true;\n\t}\n\n\t/**\n\t * Wait for a value to be available and acquire it from the consensus collection\n\t */\n\tpublic async waitAndAcquire(callback: ConsensusCallback<T>): Promise<void> {\n\t\tdo {\n\t\t\tif (this.data.size() === 0) {\n\t\t\t\t// Wait for new entry before trying to acquire again\n\t\t\t\tawait this.newAckBasedPromise<T>((resolve) => {\n\t\t\t\t\tthis.once(\"add\", resolve);\n\t\t\t\t});\n\t\t\t}\n\t\t} while (!(await this.acquire(callback)));\n\t}\n\n\tprotected summarizeCore(serializer: IFluidSerializer): ISummaryTreeWithStats {\n\t\t// If we are transitioning from unattached to attached mode,\n\t\t// then we are losing all checked out work!\n\t\tthis.removeClient(idForLocalUnattachedClient);\n\n\t\tconst builder = new SummaryTreeBuilder();\n\t\tlet blobContent = this.serializeValue(this.data.asArray(), serializer);\n\t\tbuilder.addBlob(snapshotFileNameData, blobContent);\n\t\tblobContent = this.serializeValue([...this.jobTracking.entries()], serializer);\n\t\tbuilder.addBlob(snapshotFileNameTracking, blobContent);\n\t\treturn builder.getSummaryTree();\n\t}\n\n\tprotected isActive(): boolean {\n\t\treturn this.runtime.connected && this.deltaManager.active;\n\t}\n\n\tprotected async complete(acquireId: string): Promise<void> {\n\t\tif (!this.isAttached()) {\n\t\t\tthis.completeCore(acquireId);\n\t\t\treturn;\n\t\t}\n\n\t\t// if not active, this item already was released to queue (as observed by other clients)\n\t\tif (this.isActive()) {\n\t\t\tawait this.submit<IConsensusOrderedCollectionCompleteOperation>({\n\t\t\t\topName: \"complete\",\n\t\t\t\tacquireId,\n\t\t\t});\n\t\t}\n\t}\n\n\tprotected completeCore(acquireId: string): void {\n\t\t// Note: item may be no longer in jobTracking and returned back to queue!\n\t\tconst rec = this.jobTracking.get(acquireId);\n\t\tif (rec !== undefined) {\n\t\t\tthis.jobTracking.delete(acquireId);\n\t\t\tthis.emit(\"complete\", rec.value);\n\t\t}\n\t}\n\n\tprotected release(acquireId: string): void {\n\t\tif (!this.isAttached()) {\n\t\t\tthis.releaseCore(acquireId);\n\t\t\treturn;\n\t\t}\n\n\t\t// if not active, this item already was released to queue (as observed by other clients)\n\t\tif (this.isActive()) {\n\t\t\tthis.submit<IConsensusOrderedCollectionReleaseOperation>({\n\t\t\t\topName: \"release\",\n\t\t\t\tacquireId,\n\t\t\t}).catch((error) => {\n\t\t\t\tthis.logger.sendErrorEvent({ eventName: \"ConsensusQueue_release\" }, error);\n\t\t\t});\n\t\t}\n\t}\n\n\tprotected releaseCore(acquireId: string): void {\n\t\t// Note: item may be no longer in jobTracking and returned back to queue!\n\t\tconst rec = this.jobTracking.get(acquireId);\n\t\tif (rec !== undefined) {\n\t\t\tthis.jobTracking.delete(acquireId);\n\t\t\tthis.data.add(rec.value);\n\t\t\tthis.emit(\"add\", rec.value, false /* newlyAdded */);\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}\n\t */\n\tprotected async loadCore(storage: IChannelStorageService): Promise<void> {\n\t\tassert(\n\t\t\tthis.jobTracking.size === 0,\n\t\t\t0x068 /* \"On consensusOrderedCollection load, job tracking size > 0\" */,\n\t\t);\n\t\tconst blob = await storage.readBlob(snapshotFileNameTracking);\n\t\tconst rawContentTracking = bufferToString(blob, \"utf8\");\n\t\tconst content = this.deserializeValue(rawContentTracking, this.serializer);\n\t\tthis.jobTracking = new Map(\n\t\t\tcontent as Iterable<[string, { value: T; clientId: string | undefined }]>,\n\t\t);\n\n\t\tassert(\n\t\t\tthis.data.size() === 0,\n\t\t\t0x069 /* \"On consensusOrderedCollection load, data size > 0\" */,\n\t\t);\n\t\tconst blob2 = await storage.readBlob(snapshotFileNameData);\n\t\tconst rawContentData = bufferToString(blob2, \"utf8\");\n\t\tconst content2 = this.deserializeValue(rawContentData, this.serializer) as T[];\n\t\tthis.data.loadFrom(content2);\n\t}\n\n\tprotected onDisconnect(): void {\n\t\tfor (const [, { value, clientId }] of this.jobTracking) {\n\t\t\tif (clientId === this.runtime.clientId) {\n\t\t\t\tthis.emit(\"localRelease\", value, false /* intentional */);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.processMessagesCore}\n\t */\n\tprotected processMessagesCore(messagesCollection: IRuntimeMessageCollection): void {\n\t\tconst { envelope, local, messagesContent } = messagesCollection;\n\t\tfor (const messageContent of messagesContent) {\n\t\t\tthis.processMessage(envelope, messageContent, local);\n\t\t}\n\t}\n\n\tprivate processMessage(\n\t\tmessageEnvelope: ISequencedMessageEnvelope,\n\t\tmessageContent: IRuntimeMessagesContent,\n\t\tlocal: boolean,\n\t): void {\n\t\tif (messageEnvelope.type === MessageType.Operation) {\n\t\t\tconst op = messageContent.contents as IConsensusOrderedCollectionOperation<T>;\n\t\t\tlet value: IConsensusOrderedCollectionValue<T> | undefined;\n\t\t\tswitch (op.opName) {\n\t\t\t\tcase \"add\": {\n\t\t\t\t\tif (op.deserializedValue === undefined) {\n\t\t\t\t\t\tthis.addCore(this.deserializeValue(op.value, this.serializer) as T);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.addCore(op.deserializedValue);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase \"acquire\": {\n\t\t\t\t\tvalue = this.acquireCore(op.acquireId, messageEnvelope.clientId ?? undefined);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase \"complete\": {\n\t\t\t\t\tthis.completeCore(op.acquireId);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase \"release\": {\n\t\t\t\t\tthis.releaseCore(op.acquireId);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tdefault: {\n\t\t\t\t\tunreachableCase(op);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (local) {\n\t\t\t\t// Resolve the pending promise for this operation now that we have received an ack for it.\n\t\t\t\tconst resolve = messageContent.localOpMetadata as PendingResolve<T>;\n\t\t\t\tresolve(value);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate async submit<TMessage extends IConsensusOrderedCollectionOperation<T>>(\n\t\tmessage: TMessage,\n\t): Promise<IConsensusOrderedCollectionValue<T> | undefined> {\n\t\tassert(this.isAttached(), 0x06a /* \"Trying to submit message while detached!\" */);\n\n\t\treturn this.newAckBasedPromise<IConsensusOrderedCollectionValue<T> | undefined>(\n\t\t\t(resolve) => {\n\t\t\t\t// Send the resolve function as the localOpMetadata. This will be provided back to us when the\n\t\t\t\t// op is ack'd.\n\t\t\t\tthis.submitLocalMessage(message, resolve);\n\t\t\t\t// If we fail due to runtime being disposed, it's better to return undefined then unhandled exception.\n\t\t\t},\n\t\t).catch((error) => undefined);\n\t}\n\n\tprivate addCore(value: T): void {\n\t\tthis.data.add(value);\n\t\tthis.emit(\"add\", value, true /* newlyAdded */);\n\t}\n\n\tprivate acquireCore(\n\t\tacquireId: string,\n\t\tclientId?: string,\n\t): IConsensusOrderedCollectionValue<T> | undefined {\n\t\tif (this.data.size() === 0) {\n\t\t\treturn undefined;\n\t\t}\n\t\tconst value = this.data.remove();\n\n\t\tconst value2: IConsensusOrderedCollectionValue<T> = {\n\t\t\tacquireId,\n\t\t\tvalue,\n\t\t};\n\t\tthis.jobTracking.set(value2.acquireId, { value, clientId });\n\n\t\tthis.emit(\"acquire\", value, clientId);\n\t\treturn value2;\n\t}\n\n\tprivate async acquireInternal(): Promise<IConsensusOrderedCollectionValue<T> | undefined> {\n\t\tif (!this.isAttached()) {\n\t\t\t// can be undefined if queue is empty\n\t\t\treturn this.acquireCore(uuid(), idForLocalUnattachedClient);\n\t\t}\n\n\t\treturn this.submit<IConsensusOrderedCollectionAcquireOperation>({\n\t\t\topName: \"acquire\",\n\t\t\tacquireId: uuid(),\n\t\t});\n\t}\n\n\tprivate removeClient(clientIdToRemove?: string): void {\n\t\tconst added: T[] = [];\n\t\tfor (const [acquireId, { value, clientId }] of this.jobTracking) {\n\t\t\tif (clientId === clientIdToRemove) {\n\t\t\t\tthis.jobTracking.delete(acquireId);\n\t\t\t\tthis.data.add(value);\n\t\t\t\tadded.push(value);\n\t\t\t}\n\t\t}\n\n\t\t// Raise all events only after all state changes are completed,\n\t\t// to guarantee same ordering of operations if collection is manipulated from events.\n\t\tadded.map((value) => this.emit(\"add\", value, false /* newlyAdded */));\n\t}\n\n\tprivate serializeValue(value, serializer: IFluidSerializer): string {\n\t\treturn serializer.stringify(value, this.handle);\n\t}\n\n\tprivate deserializeValue(content: string, serializer: IFluidSerializer): unknown {\n\t\treturn serializer.parse(content);\n\t}\n\n\tprotected applyStashedOp(): void {\n\t\tthrow new Error(\"not implemented\");\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.rollback}\n\t * @sealed\n\t */\n\tprotected rollback(content: unknown, localOpMetadata: unknown): void {\n\t\tassert(\n\t\t\ttypeof localOpMetadata === \"function\",\n\t\t\t0xc93 /* localOpMetadata should be a function */,\n\t\t);\n\t\t// A resolve function is passed as the localOpMetadata on this.submitLocalMessage().\n\t\t// On rollback we resolve with undefined and the promises will handle it appropriately.\n\t\tconst resolve = localOpMetadata as PendingResolve<T>;\n\t\tresolve(undefined);\n\t}\n}\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -6,5 +6,5 @@ export { type ConsensusCallback, ConsensusResult, type IConsensusOrderedCollecti
|
|
|
6
6
|
export { ConsensusQueueFactory, ConsensusQueue } from "./consensusOrderedCollectionFactory.js";
|
|
7
7
|
export { ConsensusOrderedCollection } from "./consensusOrderedCollection.js";
|
|
8
8
|
export { ConsensusQueueClass } from "./consensusQueue.js";
|
|
9
|
-
export { acquireAndComplete, waitAcquireAndComplete } from "./testUtils.js";
|
|
9
|
+
export { acquireAndComplete, waitAcquireAndComplete, acquireAndRelease, waitAcquireAndRelease, } from "./testUtils.js";
|
|
10
10
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,KAAK,iBAAiB,EACtB,eAAe,EACf,KAAK,2BAA2B,EAChC,KAAK,iCAAiC,EACtC,KAAK,kCAAkC,EACvC,KAAK,kBAAkB,EACvB,KAAK,aAAa,GAClB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AAC/F,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,KAAK,iBAAiB,EACtB,eAAe,EACf,KAAK,2BAA2B,EAChC,KAAK,iCAAiC,EACtC,KAAK,kCAAkC,EACvC,KAAK,kBAAkB,EACvB,KAAK,aAAa,GAClB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AAC/F,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EACN,kBAAkB,EAClB,sBAAsB,EACtB,iBAAiB,EACjB,qBAAqB,GACrB,MAAM,gBAAgB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.waitAcquireAndComplete = exports.acquireAndComplete = exports.ConsensusQueueClass = exports.ConsensusOrderedCollection = exports.ConsensusQueue = exports.ConsensusQueueFactory = exports.ConsensusResult = void 0;
|
|
7
|
+
exports.waitAcquireAndRelease = exports.acquireAndRelease = exports.waitAcquireAndComplete = exports.acquireAndComplete = exports.ConsensusQueueClass = exports.ConsensusOrderedCollection = exports.ConsensusQueue = exports.ConsensusQueueFactory = exports.ConsensusResult = void 0;
|
|
8
8
|
var interfaces_js_1 = require("./interfaces.js");
|
|
9
9
|
Object.defineProperty(exports, "ConsensusResult", { enumerable: true, get: function () { return interfaces_js_1.ConsensusResult; } });
|
|
10
10
|
var consensusOrderedCollectionFactory_js_1 = require("./consensusOrderedCollectionFactory.js");
|
|
@@ -17,4 +17,6 @@ Object.defineProperty(exports, "ConsensusQueueClass", { enumerable: true, get: f
|
|
|
17
17
|
var testUtils_js_1 = require("./testUtils.js");
|
|
18
18
|
Object.defineProperty(exports, "acquireAndComplete", { enumerable: true, get: function () { return testUtils_js_1.acquireAndComplete; } });
|
|
19
19
|
Object.defineProperty(exports, "waitAcquireAndComplete", { enumerable: true, get: function () { return testUtils_js_1.waitAcquireAndComplete; } });
|
|
20
|
+
Object.defineProperty(exports, "acquireAndRelease", { enumerable: true, get: function () { return testUtils_js_1.acquireAndRelease; } });
|
|
21
|
+
Object.defineProperty(exports, "waitAcquireAndRelease", { enumerable: true, get: function () { return testUtils_js_1.waitAcquireAndRelease; } });
|
|
20
22
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,iDAQyB;AANxB,gHAAA,eAAe,OAAA;AAOhB,+FAA+F;AAAtF,6IAAA,qBAAqB,OAAA;AAAE,sIAAA,cAAc,OAAA;AAC9C,iFAA6E;AAApE,2IAAA,0BAA0B,OAAA;AACnC,yDAA0D;AAAjD,wHAAA,mBAAmB,OAAA;AAC5B,+
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,iDAQyB;AANxB,gHAAA,eAAe,OAAA;AAOhB,+FAA+F;AAAtF,6IAAA,qBAAqB,OAAA;AAAE,sIAAA,cAAc,OAAA;AAC9C,iFAA6E;AAApE,2IAAA,0BAA0B,OAAA;AACnC,yDAA0D;AAAjD,wHAAA,mBAAmB,OAAA;AAC5B,+CAKwB;AAJvB,kHAAA,kBAAkB,OAAA;AAClB,sHAAA,sBAAsB,OAAA;AACtB,iHAAA,iBAAiB,OAAA;AACjB,qHAAA,qBAAqB,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\ttype ConsensusCallback,\n\tConsensusResult,\n\ttype IConsensusOrderedCollection,\n\ttype IConsensusOrderedCollectionEvents,\n\ttype IConsensusOrderedCollectionFactory,\n\ttype IOrderedCollection,\n\ttype ISnapshotable,\n} from \"./interfaces.js\";\nexport { ConsensusQueueFactory, ConsensusQueue } from \"./consensusOrderedCollectionFactory.js\";\nexport { ConsensusOrderedCollection } from \"./consensusOrderedCollection.js\";\nexport { ConsensusQueueClass } from \"./consensusQueue.js\";\nexport {\n\tacquireAndComplete,\n\twaitAcquireAndComplete,\n\tacquireAndRelease,\n\twaitAcquireAndRelease,\n} from \"./testUtils.js\";\n"]}
|
package/dist/packageVersion.d.ts
CHANGED
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
|
|
6
6
|
*/
|
|
7
7
|
export declare const pkgName = "@fluidframework/ordered-collection";
|
|
8
|
-
export declare const pkgVersion = "2.
|
|
8
|
+
export declare const pkgVersion = "2.71.0";
|
|
9
9
|
//# sourceMappingURL=packageVersion.d.ts.map
|
package/dist/packageVersion.js
CHANGED
|
@@ -8,5 +8,5 @@
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.pkgVersion = exports.pkgName = void 0;
|
|
10
10
|
exports.pkgName = "@fluidframework/ordered-collection";
|
|
11
|
-
exports.pkgVersion = "2.
|
|
11
|
+
exports.pkgVersion = "2.71.0";
|
|
12
12
|
//# sourceMappingURL=packageVersion.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,oCAAoC,CAAC;AAC/C,QAAA,UAAU,GAAG,QAAQ,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/ordered-collection\";\nexport const pkgVersion = \"2.
|
|
1
|
+
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,oCAAoC,CAAC;AAC/C,QAAA,UAAU,GAAG,QAAQ,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/ordered-collection\";\nexport const pkgVersion = \"2.71.0\";\n"]}
|
package/dist/testUtils.d.ts
CHANGED
|
@@ -15,4 +15,16 @@ export declare function acquireAndComplete<T>(collection: IConsensusOrderedColle
|
|
|
15
15
|
* @internal
|
|
16
16
|
*/
|
|
17
17
|
export declare function waitAcquireAndComplete<T>(collection: IConsensusOrderedCollection<T>): Promise<T>;
|
|
18
|
+
/**
|
|
19
|
+
* Helper method to acquire and release an item
|
|
20
|
+
* Should be used in test code only
|
|
21
|
+
* @internal
|
|
22
|
+
*/
|
|
23
|
+
export declare function acquireAndRelease<T>(collection: IConsensusOrderedCollection<T>): Promise<T | undefined>;
|
|
24
|
+
/**
|
|
25
|
+
* Helper method to acquire and release an item
|
|
26
|
+
* Should be used in test code only
|
|
27
|
+
* @internal
|
|
28
|
+
*/
|
|
29
|
+
export declare function waitAcquireAndRelease<T>(collection: IConsensusOrderedCollection<T>): Promise<T>;
|
|
18
30
|
//# sourceMappingURL=testUtils.d.ts.map
|
package/dist/testUtils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testUtils.d.ts","sourceRoot":"","sources":["../src/testUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAmB,KAAK,2BAA2B,EAAE,MAAM,iBAAiB,CAAC;AAEpF;;;;GAIG;AACH,wBAAsB,kBAAkB,CAAC,CAAC,EACzC,UAAU,EAAE,2BAA2B,CAAC,CAAC,CAAC,GACxC,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,CAOxB;AAED;;;;GAIG;AACH,wBAAsB,sBAAsB,CAAC,CAAC,EAC7C,UAAU,EAAE,2BAA2B,CAAC,CAAC,CAAC,GACxC,OAAO,CAAC,CAAC,CAAC,CAOZ"}
|
|
1
|
+
{"version":3,"file":"testUtils.d.ts","sourceRoot":"","sources":["../src/testUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAmB,KAAK,2BAA2B,EAAE,MAAM,iBAAiB,CAAC;AAEpF;;;;GAIG;AACH,wBAAsB,kBAAkB,CAAC,CAAC,EACzC,UAAU,EAAE,2BAA2B,CAAC,CAAC,CAAC,GACxC,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,CAOxB;AAED;;;;GAIG;AACH,wBAAsB,sBAAsB,CAAC,CAAC,EAC7C,UAAU,EAAE,2BAA2B,CAAC,CAAC,CAAC,GACxC,OAAO,CAAC,CAAC,CAAC,CAOZ;AAED;;;;GAIG;AACH,wBAAsB,iBAAiB,CAAC,CAAC,EACxC,UAAU,EAAE,2BAA2B,CAAC,CAAC,CAAC,GACxC,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,CAOxB;AAED;;;;GAIG;AACH,wBAAsB,qBAAqB,CAAC,CAAC,EAC5C,UAAU,EAAE,2BAA2B,CAAC,CAAC,CAAC,GACxC,OAAO,CAAC,CAAC,CAAC,CAOZ"}
|
package/dist/testUtils.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.waitAcquireAndComplete = exports.acquireAndComplete = void 0;
|
|
7
|
+
exports.waitAcquireAndRelease = exports.acquireAndRelease = exports.waitAcquireAndComplete = exports.acquireAndComplete = void 0;
|
|
8
8
|
const interfaces_js_1 = require("./interfaces.js");
|
|
9
9
|
/**
|
|
10
10
|
* Helper method to acquire and complete an item
|
|
@@ -34,4 +34,32 @@ async function waitAcquireAndComplete(collection) {
|
|
|
34
34
|
return res;
|
|
35
35
|
}
|
|
36
36
|
exports.waitAcquireAndComplete = waitAcquireAndComplete;
|
|
37
|
+
/**
|
|
38
|
+
* Helper method to acquire and release an item
|
|
39
|
+
* Should be used in test code only
|
|
40
|
+
* @internal
|
|
41
|
+
*/
|
|
42
|
+
async function acquireAndRelease(collection) {
|
|
43
|
+
let res;
|
|
44
|
+
await collection.acquire(async (value) => {
|
|
45
|
+
res = value;
|
|
46
|
+
return interfaces_js_1.ConsensusResult.Release;
|
|
47
|
+
});
|
|
48
|
+
return res;
|
|
49
|
+
}
|
|
50
|
+
exports.acquireAndRelease = acquireAndRelease;
|
|
51
|
+
/**
|
|
52
|
+
* Helper method to acquire and release an item
|
|
53
|
+
* Should be used in test code only
|
|
54
|
+
* @internal
|
|
55
|
+
*/
|
|
56
|
+
async function waitAcquireAndRelease(collection) {
|
|
57
|
+
let res;
|
|
58
|
+
await collection.waitAndAcquire(async (value) => {
|
|
59
|
+
res = value;
|
|
60
|
+
return interfaces_js_1.ConsensusResult.Release;
|
|
61
|
+
});
|
|
62
|
+
return res;
|
|
63
|
+
}
|
|
64
|
+
exports.waitAcquireAndRelease = waitAcquireAndRelease;
|
|
37
65
|
//# sourceMappingURL=testUtils.js.map
|
package/dist/testUtils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testUtils.js","sourceRoot":"","sources":["../src/testUtils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,mDAAoF;AAEpF;;;;GAIG;AACI,KAAK,UAAU,kBAAkB,CACvC,UAA0C;IAE1C,IAAI,GAAkB,CAAC;IACvB,MAAM,UAAU,CAAC,OAAO,CAAC,KAAK,EAAE,KAAQ,EAAE,EAAE;QAC3C,GAAG,GAAG,KAAK,CAAC;QACZ,OAAO,+BAAe,CAAC,QAAQ,CAAC;IACjC,CAAC,CAAC,CAAC;IACH,OAAO,GAAG,CAAC;AACZ,CAAC;AATD,gDASC;AAED;;;;GAIG;AACI,KAAK,UAAU,sBAAsB,CAC3C,UAA0C;IAE1C,IAAI,GAAkB,CAAC;IACvB,MAAM,UAAU,CAAC,cAAc,CAAC,KAAK,EAAE,KAAQ,EAAE,EAAE;QAClD,GAAG,GAAG,KAAK,CAAC;QACZ,OAAO,+BAAe,CAAC,QAAQ,CAAC;IACjC,CAAC,CAAC,CAAC;IACH,OAAO,GAAQ,CAAC;AACjB,CAAC;AATD,wDASC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ConsensusResult, type IConsensusOrderedCollection } from \"./interfaces.js\";\n\n/**\n * Helper method to acquire and complete an item\n * Should be used in test code only\n * @internal\n */\nexport async function acquireAndComplete<T>(\n\tcollection: IConsensusOrderedCollection<T>,\n): Promise<T | undefined> {\n\tlet res: T | undefined;\n\tawait collection.acquire(async (value: T) => {\n\t\tres = value;\n\t\treturn ConsensusResult.Complete;\n\t});\n\treturn res;\n}\n\n/**\n * Helper method to acquire and complete an item\n * Should be used in test code only\n * @internal\n */\nexport async function waitAcquireAndComplete<T>(\n\tcollection: IConsensusOrderedCollection<T>,\n): Promise<T> {\n\tlet res: T | undefined;\n\tawait collection.waitAndAcquire(async (value: T) => {\n\t\tres = value;\n\t\treturn ConsensusResult.Complete;\n\t});\n\treturn res as T;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"testUtils.js","sourceRoot":"","sources":["../src/testUtils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,mDAAoF;AAEpF;;;;GAIG;AACI,KAAK,UAAU,kBAAkB,CACvC,UAA0C;IAE1C,IAAI,GAAkB,CAAC;IACvB,MAAM,UAAU,CAAC,OAAO,CAAC,KAAK,EAAE,KAAQ,EAAE,EAAE;QAC3C,GAAG,GAAG,KAAK,CAAC;QACZ,OAAO,+BAAe,CAAC,QAAQ,CAAC;IACjC,CAAC,CAAC,CAAC;IACH,OAAO,GAAG,CAAC;AACZ,CAAC;AATD,gDASC;AAED;;;;GAIG;AACI,KAAK,UAAU,sBAAsB,CAC3C,UAA0C;IAE1C,IAAI,GAAkB,CAAC;IACvB,MAAM,UAAU,CAAC,cAAc,CAAC,KAAK,EAAE,KAAQ,EAAE,EAAE;QAClD,GAAG,GAAG,KAAK,CAAC;QACZ,OAAO,+BAAe,CAAC,QAAQ,CAAC;IACjC,CAAC,CAAC,CAAC;IACH,OAAO,GAAQ,CAAC;AACjB,CAAC;AATD,wDASC;AAED;;;;GAIG;AACI,KAAK,UAAU,iBAAiB,CACtC,UAA0C;IAE1C,IAAI,GAAkB,CAAC;IACvB,MAAM,UAAU,CAAC,OAAO,CAAC,KAAK,EAAE,KAAQ,EAAE,EAAE;QAC3C,GAAG,GAAG,KAAK,CAAC;QACZ,OAAO,+BAAe,CAAC,OAAO,CAAC;IAChC,CAAC,CAAC,CAAC;IACH,OAAO,GAAG,CAAC;AACZ,CAAC;AATD,8CASC;AAED;;;;GAIG;AACI,KAAK,UAAU,qBAAqB,CAC1C,UAA0C;IAE1C,IAAI,GAAkB,CAAC;IACvB,MAAM,UAAU,CAAC,cAAc,CAAC,KAAK,EAAE,KAAQ,EAAE,EAAE;QAClD,GAAG,GAAG,KAAK,CAAC;QACZ,OAAO,+BAAe,CAAC,OAAO,CAAC;IAChC,CAAC,CAAC,CAAC;IACH,OAAO,GAAQ,CAAC;AACjB,CAAC;AATD,sDASC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ConsensusResult, type IConsensusOrderedCollection } from \"./interfaces.js\";\n\n/**\n * Helper method to acquire and complete an item\n * Should be used in test code only\n * @internal\n */\nexport async function acquireAndComplete<T>(\n\tcollection: IConsensusOrderedCollection<T>,\n): Promise<T | undefined> {\n\tlet res: T | undefined;\n\tawait collection.acquire(async (value: T) => {\n\t\tres = value;\n\t\treturn ConsensusResult.Complete;\n\t});\n\treturn res;\n}\n\n/**\n * Helper method to acquire and complete an item\n * Should be used in test code only\n * @internal\n */\nexport async function waitAcquireAndComplete<T>(\n\tcollection: IConsensusOrderedCollection<T>,\n): Promise<T> {\n\tlet res: T | undefined;\n\tawait collection.waitAndAcquire(async (value: T) => {\n\t\tres = value;\n\t\treturn ConsensusResult.Complete;\n\t});\n\treturn res as T;\n}\n\n/**\n * Helper method to acquire and release an item\n * Should be used in test code only\n * @internal\n */\nexport async function acquireAndRelease<T>(\n\tcollection: IConsensusOrderedCollection<T>,\n): Promise<T | undefined> {\n\tlet res: T | undefined;\n\tawait collection.acquire(async (value: T) => {\n\t\tres = value;\n\t\treturn ConsensusResult.Release;\n\t});\n\treturn res;\n}\n\n/**\n * Helper method to acquire and release an item\n * Should be used in test code only\n * @internal\n */\nexport async function waitAcquireAndRelease<T>(\n\tcollection: IConsensusOrderedCollection<T>,\n): Promise<T> {\n\tlet res: T | undefined;\n\tawait collection.waitAndAcquire(async (value: T) => {\n\t\tres = value;\n\t\treturn ConsensusResult.Release;\n\t});\n\treturn res as T;\n}\n"]}
|
|
@@ -64,5 +64,10 @@ export declare class ConsensusOrderedCollection<T = any> extends SharedObject<IC
|
|
|
64
64
|
private serializeValue;
|
|
65
65
|
private deserializeValue;
|
|
66
66
|
protected applyStashedOp(): void;
|
|
67
|
+
/**
|
|
68
|
+
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.rollback}
|
|
69
|
+
* @sealed
|
|
70
|
+
*/
|
|
71
|
+
protected rollback(content: unknown, localOpMetadata: unknown): void;
|
|
67
72
|
}
|
|
68
73
|
//# sourceMappingURL=consensusOrderedCollection.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"consensusOrderedCollection.d.ts","sourceRoot":"","sources":["../src/consensusOrderedCollection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EACX,kBAAkB,EAClB,sBAAsB,EACtB,sBAAsB,EACtB,MAAM,gDAAgD,CAAC;AAExD,OAAO,KAAK,E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AAI;CAUpE"}
|
|
@@ -287,5 +287,16 @@ export class ConsensusOrderedCollection extends SharedObject {
|
|
|
287
287
|
applyStashedOp() {
|
|
288
288
|
throw new Error("not implemented");
|
|
289
289
|
}
|
|
290
|
+
/**
|
|
291
|
+
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.rollback}
|
|
292
|
+
* @sealed
|
|
293
|
+
*/
|
|
294
|
+
rollback(content, localOpMetadata) {
|
|
295
|
+
assert(typeof localOpMetadata === "function", 0xc93 /* localOpMetadata should be a function */);
|
|
296
|
+
// A resolve function is passed as the localOpMetadata on this.submitLocalMessage().
|
|
297
|
+
// On rollback we resolve with undefined and the promises will handle it appropriately.
|
|
298
|
+
const resolve = localOpMetadata;
|
|
299
|
+
resolve(undefined);
|
|
300
|
+
}
|
|
290
301
|
}
|
|
291
302
|
//# sourceMappingURL=consensusOrderedCollection.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"consensusOrderedCollection.js","sourceRoot":"","sources":["../src/consensusOrderedCollection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAM9E,OAAO,EAAE,WAAW,EAAE,MAAM,6CAA6C,CAAC;AAO1E,OAAO,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AAC5E,OAAO,EAEN,YAAY,GACZ,MAAM,6CAA6C,CAAC;AACrD,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAElC,OAAO,EAEN,eAAe,GAIf,MAAM,iBAAiB,CAAC;AAEzB,MAAM,oBAAoB,GAAG,QAAQ,CAAC;AACtC,MAAM,wBAAwB,GAAG,aAAa,CAAC;AA2D/C,MAAM,0BAA0B,GAAG,SAAS,CAAC;AAE7C;;;;;;;;;GASG;AAEH,8DAA8D;AAC9D,8DAA8D;AAC9D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Y,CAAC,gBAAyB;QAC7C,MAAM,KAAK,GAAQ,EAAE,CAAC;QACtB,KAAK,MAAM,CAAC,SAAS,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YACjE,IAAI,QAAQ,KAAK,gBAAgB,EAAE,CAAC;gBACnC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;gBACnC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;gBACrB,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACnB,CAAC;QACF,CAAC;QAED,+DAA+D;QAC/D,qFAAqF;QACrF,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,gBAAgB,CAAC,CAAC,CAAC;IACvE,CAAC;IAEO,cAAc,CAAC,KAAK,EAAE,UAA4B;QACzD,OAAO,UAAU,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IACjD,CAAC;IAEO,gBAAgB,CAAC,OAAe,EAAE,UAA4B;QACrE,OAAO,UAAU,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAClC,CAAC;IAES,cAAc;QACvB,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACpC,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { bufferToString } from \"@fluid-internal/client-utils\";\nimport { assert, unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport type {\n\tIChannelAttributes,\n\tIFluidDataStoreRuntime,\n\tIChannelStorageService,\n} from \"@fluidframework/datastore-definitions/internal\";\nimport { MessageType } from \"@fluidframework/driver-definitions/internal\";\nimport type {\n\tISummaryTreeWithStats,\n\tIRuntimeMessageCollection,\n\tIRuntimeMessagesContent,\n\tISequencedMessageEnvelope,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport { SummaryTreeBuilder } from \"@fluidframework/runtime-utils/internal\";\nimport {\n\ttype IFluidSerializer,\n\tSharedObject,\n} from \"@fluidframework/shared-object-base/internal\";\nimport { v4 as uuid } from \"uuid\";\n\nimport {\n\ttype ConsensusCallback,\n\tConsensusResult,\n\ttype IConsensusOrderedCollection,\n\ttype IConsensusOrderedCollectionEvents,\n\ttype IOrderedCollection,\n} from \"./interfaces.js\";\n\nconst snapshotFileNameData = \"header\";\nconst snapshotFileNameTracking = \"jobTracking\";\n\ninterface IConsensusOrderedCollectionValue<T> {\n\t// an ID used to indicate acquired item.\n\t// Used in acquire/release/complete ops.\n\treadonly acquireId: string;\n\n\t// The actual value\n\treadonly value: T;\n}\n\n/**\n * An operation for consensus ordered collection\n */\ninterface IConsensusOrderedCollectionAddOperation<T> {\n\topName: \"add\";\n\t// serialized value\n\tvalue: string;\n\tdeserializedValue?: T;\n}\n\ninterface IConsensusOrderedCollectionAcquireOperation {\n\topName: \"acquire\";\n\t// an ID used to indicate acquired item.\n\t// Used in acquire/release/complete ops.\n\tacquireId: string;\n}\n\ninterface IConsensusOrderedCollectionCompleteOperation {\n\topName: \"complete\";\n\t// an ID used to indicate acquired item.\n\t// Used in acquire/release/complete ops.\n\tacquireId: string;\n}\n\ninterface IConsensusOrderedCollectionReleaseOperation {\n\topName: \"release\";\n\t// an ID used to indicate acquired item.\n\t// Used in acquire/release/complete ops.\n\tacquireId: string;\n}\n\ntype IConsensusOrderedCollectionOperation<T> =\n\t| IConsensusOrderedCollectionAddOperation<T>\n\t| IConsensusOrderedCollectionAcquireOperation\n\t| IConsensusOrderedCollectionCompleteOperation\n\t| IConsensusOrderedCollectionReleaseOperation;\n\n/**\n * The type of the resolve function to call after the local operation is acknowledged.\n */\ntype PendingResolve<T> = (value: IConsensusOrderedCollectionValue<T> | undefined) => void;\n\n/**\n * For job tracking, we need to keep track of which client \"owns\" a given value.\n * Key is the acquireId from when it was acquired\n * Value is the acquired value, and the id of the client who acquired it, or undefined for unattached client\n */\ntype JobTrackingInfo<T> = Map<string, { value: T; clientId: string | undefined }>;\nconst idForLocalUnattachedClient = undefined;\n\n/**\n * Implementation of a consensus collection shared object\n *\n * Implements the shared object's communication, and the semantics around the\n * release/complete mechanism following acquire.\n *\n * Generally not used directly. A derived type will pass in a backing data type\n * IOrderedCollection that will define the deterministic add/acquire order and snapshot ability.\n * @legacy @beta\n */\n\n// TODO: #22835 Use undefined instead of any (breaking change)\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport class ConsensusOrderedCollection<T = any>\n\textends SharedObject<IConsensusOrderedCollectionEvents<T>>\n\timplements IConsensusOrderedCollection<T>\n{\n\t/**\n\t * The set of values that have been acquired but not yet completed or released\n\t */\n\tprivate jobTracking: JobTrackingInfo<T> = new Map();\n\n\t/**\n\t * Constructs a new consensus collection. If the object is non-local an id and service interfaces will\n\t * be provided\n\t */\n\tprotected constructor(\n\t\tid: string,\n\t\truntime: IFluidDataStoreRuntime,\n\t\tattributes: IChannelAttributes,\n\t\tprivate readonly data: IOrderedCollection<T>,\n\t) {\n\t\tsuper(id, runtime, attributes, \"fluid_consensusOrderedCollection_\");\n\n\t\t// We can't simply call this.removeClient(this.runtime.clientId) in on runtime disconnected,\n\t\t// because other clients may disconnect concurrently.\n\t\t// Disconnect order matters because it defines the order items go back to the queue.\n\t\t// So we put items back to queue only when we process our own removeMember event.\n\t\truntime.getQuorum().on(\"removeMember\", (clientId: string) => {\n\t\t\tassert(!!clientId, 0x067 /* \"Missing clientId for removal!\" */);\n\t\t\tthis.removeClient(clientId);\n\t\t});\n\t}\n\n\t/**\n\t * Add a value to the consensus collection.\n\t */\n\tpublic async add(value: T): Promise<void> {\n\t\tconst valueSer = this.serializeValue(value, this.serializer);\n\n\t\tif (!this.isAttached()) {\n\t\t\t// For the case where this is not attached yet, explicitly JSON\n\t\t\t// clone the value to match the behavior of going thru the wire.\n\t\t\tconst addValue = this.deserializeValue(valueSer, this.serializer) as T;\n\t\t\tthis.addCore(addValue);\n\t\t\treturn;\n\t\t}\n\n\t\tawait this.submit<IConsensusOrderedCollectionAddOperation<T>>({\n\t\t\topName: \"add\",\n\t\t\tvalue: valueSer,\n\t\t\tdeserializedValue: value,\n\t\t});\n\t}\n\n\t/**\n\t * Remove a value from the consensus collection. If the collection is empty, returns false.\n\t * Otherwise calls callback with the value\n\t */\n\tpublic async acquire(callback: ConsensusCallback<T>): Promise<boolean> {\n\t\tconst result = await this.acquireInternal();\n\t\tif (result === undefined) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst res = await callback(result.value);\n\n\t\tswitch (res) {\n\t\t\tcase ConsensusResult.Complete: {\n\t\t\t\tawait this.complete(result.acquireId);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase ConsensusResult.Release: {\n\t\t\t\tthis.release(result.acquireId);\n\t\t\t\tthis.emit(\"localRelease\", result.value, true /* intentional */);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tunreachableCase(res);\n\t\t\t}\n\t\t}\n\n\t\treturn true;\n\t}\n\n\t/**\n\t * Wait for a value to be available and acquire it from the consensus collection\n\t */\n\tpublic async waitAndAcquire(callback: ConsensusCallback<T>): Promise<void> {\n\t\tdo {\n\t\t\tif (this.data.size() === 0) {\n\t\t\t\t// Wait for new entry before trying to acquire again\n\t\t\t\tawait this.newAckBasedPromise<T>((resolve) => {\n\t\t\t\t\tthis.once(\"add\", resolve);\n\t\t\t\t});\n\t\t\t}\n\t\t} while (!(await this.acquire(callback)));\n\t}\n\n\tprotected summarizeCore(serializer: IFluidSerializer): ISummaryTreeWithStats {\n\t\t// If we are transitioning from unattached to attached mode,\n\t\t// then we are losing all checked out work!\n\t\tthis.removeClient(idForLocalUnattachedClient);\n\n\t\tconst builder = new SummaryTreeBuilder();\n\t\tlet blobContent = this.serializeValue(this.data.asArray(), serializer);\n\t\tbuilder.addBlob(snapshotFileNameData, blobContent);\n\t\tblobContent = this.serializeValue([...this.jobTracking.entries()], serializer);\n\t\tbuilder.addBlob(snapshotFileNameTracking, blobContent);\n\t\treturn builder.getSummaryTree();\n\t}\n\n\tprotected isActive(): boolean {\n\t\treturn this.runtime.connected && this.deltaManager.active;\n\t}\n\n\tprotected async complete(acquireId: string): Promise<void> {\n\t\tif (!this.isAttached()) {\n\t\t\tthis.completeCore(acquireId);\n\t\t\treturn;\n\t\t}\n\n\t\t// if not active, this item already was released to queue (as observed by other clients)\n\t\tif (this.isActive()) {\n\t\t\tawait this.submit<IConsensusOrderedCollectionCompleteOperation>({\n\t\t\t\topName: \"complete\",\n\t\t\t\tacquireId,\n\t\t\t});\n\t\t}\n\t}\n\n\tprotected completeCore(acquireId: string): void {\n\t\t// Note: item may be no longer in jobTracking and returned back to queue!\n\t\tconst rec = this.jobTracking.get(acquireId);\n\t\tif (rec !== undefined) {\n\t\t\tthis.jobTracking.delete(acquireId);\n\t\t\tthis.emit(\"complete\", rec.value);\n\t\t}\n\t}\n\n\tprotected release(acquireId: string): void {\n\t\tif (!this.isAttached()) {\n\t\t\tthis.releaseCore(acquireId);\n\t\t\treturn;\n\t\t}\n\n\t\t// if not active, this item already was released to queue (as observed by other clients)\n\t\tif (this.isActive()) {\n\t\t\tthis.submit<IConsensusOrderedCollectionReleaseOperation>({\n\t\t\t\topName: \"release\",\n\t\t\t\tacquireId,\n\t\t\t}).catch((error) => {\n\t\t\t\tthis.logger.sendErrorEvent({ eventName: \"ConsensusQueue_release\" }, error);\n\t\t\t});\n\t\t}\n\t}\n\n\tprotected releaseCore(acquireId: string): void {\n\t\t// Note: item may be no longer in jobTracking and returned back to queue!\n\t\tconst rec = this.jobTracking.get(acquireId);\n\t\tif (rec !== undefined) {\n\t\t\tthis.jobTracking.delete(acquireId);\n\t\t\tthis.data.add(rec.value);\n\t\t\tthis.emit(\"add\", rec.value, false /* newlyAdded */);\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}\n\t */\n\tprotected async loadCore(storage: IChannelStorageService): Promise<void> {\n\t\tassert(\n\t\t\tthis.jobTracking.size === 0,\n\t\t\t0x068 /* \"On consensusOrderedCollection load, job tracking size > 0\" */,\n\t\t);\n\t\tconst blob = await storage.readBlob(snapshotFileNameTracking);\n\t\tconst rawContentTracking = bufferToString(blob, \"utf8\");\n\t\tconst content = this.deserializeValue(rawContentTracking, this.serializer);\n\t\tthis.jobTracking = new Map(\n\t\t\tcontent as Iterable<[string, { value: T; clientId: string | undefined }]>,\n\t\t);\n\n\t\tassert(\n\t\t\tthis.data.size() === 0,\n\t\t\t0x069 /* \"On consensusOrderedCollection load, data size > 0\" */,\n\t\t);\n\t\tconst blob2 = await storage.readBlob(snapshotFileNameData);\n\t\tconst rawContentData = bufferToString(blob2, \"utf8\");\n\t\tconst content2 = this.deserializeValue(rawContentData, this.serializer) as T[];\n\t\tthis.data.loadFrom(content2);\n\t}\n\n\tprotected onDisconnect(): void {\n\t\tfor (const [, { value, clientId }] of this.jobTracking) {\n\t\t\tif (clientId === this.runtime.clientId) {\n\t\t\t\tthis.emit(\"localRelease\", value, false /* intentional */);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.processMessagesCore}\n\t */\n\tprotected processMessagesCore(messagesCollection: IRuntimeMessageCollection): void {\n\t\tconst { envelope, local, messagesContent } = messagesCollection;\n\t\tfor (const messageContent of messagesContent) {\n\t\t\tthis.processMessage(envelope, messageContent, local);\n\t\t}\n\t}\n\n\tprivate processMessage(\n\t\tmessageEnvelope: ISequencedMessageEnvelope,\n\t\tmessageContent: IRuntimeMessagesContent,\n\t\tlocal: boolean,\n\t): void {\n\t\tif (messageEnvelope.type === MessageType.Operation) {\n\t\t\tconst op = messageContent.contents as IConsensusOrderedCollectionOperation<T>;\n\t\t\tlet value: IConsensusOrderedCollectionValue<T> | undefined;\n\t\t\tswitch (op.opName) {\n\t\t\t\tcase \"add\": {\n\t\t\t\t\tif (op.deserializedValue === undefined) {\n\t\t\t\t\t\tthis.addCore(this.deserializeValue(op.value, this.serializer) as T);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.addCore(op.deserializedValue);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase \"acquire\": {\n\t\t\t\t\tvalue = this.acquireCore(op.acquireId, messageEnvelope.clientId ?? undefined);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase \"complete\": {\n\t\t\t\t\tthis.completeCore(op.acquireId);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase \"release\": {\n\t\t\t\t\tthis.releaseCore(op.acquireId);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tdefault: {\n\t\t\t\t\tunreachableCase(op);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (local) {\n\t\t\t\t// Resolve the pending promise for this operation now that we have received an ack for it.\n\t\t\t\tconst resolve = messageContent.localOpMetadata as PendingResolve<T>;\n\t\t\t\tresolve(value);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate async submit<TMessage extends IConsensusOrderedCollectionOperation<T>>(\n\t\tmessage: TMessage,\n\t): Promise<IConsensusOrderedCollectionValue<T> | undefined> {\n\t\tassert(this.isAttached(), 0x06a /* \"Trying to submit message while detached!\" */);\n\n\t\treturn this.newAckBasedPromise<IConsensusOrderedCollectionValue<T> | undefined>(\n\t\t\t(resolve) => {\n\t\t\t\t// Send the resolve function as the localOpMetadata. This will be provided back to us when the\n\t\t\t\t// op is ack'd.\n\t\t\t\tthis.submitLocalMessage(message, resolve);\n\t\t\t\t// If we fail due to runtime being disposed, it's better to return undefined then unhandled exception.\n\t\t\t},\n\t\t).catch((error) => undefined);\n\t}\n\n\tprivate addCore(value: T): void {\n\t\tthis.data.add(value);\n\t\tthis.emit(\"add\", value, true /* newlyAdded */);\n\t}\n\n\tprivate acquireCore(\n\t\tacquireId: string,\n\t\tclientId?: string,\n\t): IConsensusOrderedCollectionValue<T> | undefined {\n\t\tif (this.data.size() === 0) {\n\t\t\treturn undefined;\n\t\t}\n\t\tconst value = this.data.remove();\n\n\t\tconst value2: IConsensusOrderedCollectionValue<T> = {\n\t\t\tacquireId,\n\t\t\tvalue,\n\t\t};\n\t\tthis.jobTracking.set(value2.acquireId, { value, clientId });\n\n\t\tthis.emit(\"acquire\", value, clientId);\n\t\treturn value2;\n\t}\n\n\tprivate async acquireInternal(): Promise<IConsensusOrderedCollectionValue<T> | undefined> {\n\t\tif (!this.isAttached()) {\n\t\t\t// can be undefined if queue is empty\n\t\t\treturn this.acquireCore(uuid(), idForLocalUnattachedClient);\n\t\t}\n\n\t\treturn this.submit<IConsensusOrderedCollectionAcquireOperation>({\n\t\t\topName: \"acquire\",\n\t\t\tacquireId: uuid(),\n\t\t});\n\t}\n\n\tprivate removeClient(clientIdToRemove?: string): void {\n\t\tconst added: T[] = [];\n\t\tfor (const [acquireId, { value, clientId }] of this.jobTracking) {\n\t\t\tif (clientId === clientIdToRemove) {\n\t\t\t\tthis.jobTracking.delete(acquireId);\n\t\t\t\tthis.data.add(value);\n\t\t\t\tadded.push(value);\n\t\t\t}\n\t\t}\n\n\t\t// Raise all events only after all state changes are completed,\n\t\t// to guarantee same ordering of operations if collection is manipulated from events.\n\t\tadded.map((value) => this.emit(\"add\", value, false /* newlyAdded */));\n\t}\n\n\tprivate serializeValue(value, serializer: IFluidSerializer): string {\n\t\treturn serializer.stringify(value, this.handle);\n\t}\n\n\tprivate deserializeValue(content: string, serializer: IFluidSerializer): unknown {\n\t\treturn serializer.parse(content);\n\t}\n\n\tprotected applyStashedOp(): void {\n\t\tthrow new Error(\"not implemented\");\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"consensusOrderedCollection.js","sourceRoot":"","sources":["../src/consensusOrderedCollection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,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,MAAM,CAAC,CAAC;IACjD,CAAC;IAEO,gBAAgB,CAAC,OAAe,EAAE,UAA4B;QACrE,OAAO,UAAU,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAClC,CAAC;IAES,cAAc;QACvB,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACpC,CAAC;IAED;;;OAGG;IACO,QAAQ,CAAC,OAAgB,EAAE,eAAwB;QAC5D,MAAM,CACL,OAAO,eAAe,KAAK,UAAU,EACrC,KAAK,CAAC,0CAA0C,CAChD,CAAC;QACF,oFAAoF;QACpF,uFAAuF;QACvF,MAAM,OAAO,GAAG,eAAoC,CAAC;QACrD,OAAO,CAAC,SAAS,CAAC,CAAC;IACpB,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { bufferToString } from \"@fluid-internal/client-utils\";\nimport { assert, unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport type {\n\tIChannelAttributes,\n\tIFluidDataStoreRuntime,\n\tIChannelStorageService,\n} from \"@fluidframework/datastore-definitions/internal\";\nimport { MessageType } from \"@fluidframework/driver-definitions/internal\";\nimport type {\n\tISummaryTreeWithStats,\n\tIRuntimeMessageCollection,\n\tIRuntimeMessagesContent,\n\tISequencedMessageEnvelope,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport { SummaryTreeBuilder } from \"@fluidframework/runtime-utils/internal\";\nimport {\n\ttype IFluidSerializer,\n\tSharedObject,\n} from \"@fluidframework/shared-object-base/internal\";\nimport { v4 as uuid } from \"uuid\";\n\nimport {\n\ttype ConsensusCallback,\n\tConsensusResult,\n\ttype IConsensusOrderedCollection,\n\ttype IConsensusOrderedCollectionEvents,\n\ttype IOrderedCollection,\n} from \"./interfaces.js\";\n\nconst snapshotFileNameData = \"header\";\nconst snapshotFileNameTracking = \"jobTracking\";\n\ninterface IConsensusOrderedCollectionValue<T> {\n\t// an ID used to indicate acquired item.\n\t// Used in acquire/release/complete ops.\n\treadonly acquireId: string;\n\n\t// The actual value\n\treadonly value: T;\n}\n\n/**\n * An operation for consensus ordered collection\n */\ninterface IConsensusOrderedCollectionAddOperation<T> {\n\topName: \"add\";\n\t// serialized value\n\tvalue: string;\n\tdeserializedValue?: T;\n}\n\ninterface IConsensusOrderedCollectionAcquireOperation {\n\topName: \"acquire\";\n\t// an ID used to indicate acquired item.\n\t// Used in acquire/release/complete ops.\n\tacquireId: string;\n}\n\ninterface IConsensusOrderedCollectionCompleteOperation {\n\topName: \"complete\";\n\t// an ID used to indicate acquired item.\n\t// Used in acquire/release/complete ops.\n\tacquireId: string;\n}\n\ninterface IConsensusOrderedCollectionReleaseOperation {\n\topName: \"release\";\n\t// an ID used to indicate acquired item.\n\t// Used in acquire/release/complete ops.\n\tacquireId: string;\n}\n\ntype IConsensusOrderedCollectionOperation<T> =\n\t| IConsensusOrderedCollectionAddOperation<T>\n\t| IConsensusOrderedCollectionAcquireOperation\n\t| IConsensusOrderedCollectionCompleteOperation\n\t| IConsensusOrderedCollectionReleaseOperation;\n\n/**\n * The type of the resolve function to call after the local operation is acknowledged.\n */\ntype PendingResolve<T> = (value: IConsensusOrderedCollectionValue<T> | undefined) => void;\n\n/**\n * For job tracking, we need to keep track of which client \"owns\" a given value.\n * Key is the acquireId from when it was acquired\n * Value is the acquired value, and the id of the client who acquired it, or undefined for unattached client\n */\ntype JobTrackingInfo<T> = Map<string, { value: T; clientId: string | undefined }>;\nconst idForLocalUnattachedClient = undefined;\n\n/**\n * Implementation of a consensus collection shared object\n *\n * Implements the shared object's communication, and the semantics around the\n * release/complete mechanism following acquire.\n *\n * Generally not used directly. A derived type will pass in a backing data type\n * IOrderedCollection that will define the deterministic add/acquire order and snapshot ability.\n * @legacy @beta\n */\n\n// TODO: #22835 Use undefined instead of any (breaking change)\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport class ConsensusOrderedCollection<T = any>\n\textends SharedObject<IConsensusOrderedCollectionEvents<T>>\n\timplements IConsensusOrderedCollection<T>\n{\n\t/**\n\t * The set of values that have been acquired but not yet completed or released\n\t */\n\tprivate jobTracking: JobTrackingInfo<T> = new Map();\n\n\t/**\n\t * Constructs a new consensus collection. If the object is non-local an id and service interfaces will\n\t * be provided\n\t */\n\tprotected constructor(\n\t\tid: string,\n\t\truntime: IFluidDataStoreRuntime,\n\t\tattributes: IChannelAttributes,\n\t\tprivate readonly data: IOrderedCollection<T>,\n\t) {\n\t\tsuper(id, runtime, attributes, \"fluid_consensusOrderedCollection_\");\n\n\t\t// We can't simply call this.removeClient(this.runtime.clientId) in on runtime disconnected,\n\t\t// because other clients may disconnect concurrently.\n\t\t// Disconnect order matters because it defines the order items go back to the queue.\n\t\t// So we put items back to queue only when we process our own removeMember event.\n\t\truntime.getQuorum().on(\"removeMember\", (clientId: string) => {\n\t\t\tassert(!!clientId, 0x067 /* \"Missing clientId for removal!\" */);\n\t\t\tthis.removeClient(clientId);\n\t\t});\n\t}\n\n\t/**\n\t * Add a value to the consensus collection.\n\t */\n\tpublic async add(value: T): Promise<void> {\n\t\tconst valueSer = this.serializeValue(value, this.serializer);\n\n\t\tif (!this.isAttached()) {\n\t\t\t// For the case where this is not attached yet, explicitly JSON\n\t\t\t// clone the value to match the behavior of going thru the wire.\n\t\t\tconst addValue = this.deserializeValue(valueSer, this.serializer) as T;\n\t\t\tthis.addCore(addValue);\n\t\t\treturn;\n\t\t}\n\n\t\tawait this.submit<IConsensusOrderedCollectionAddOperation<T>>({\n\t\t\topName: \"add\",\n\t\t\tvalue: valueSer,\n\t\t\tdeserializedValue: value,\n\t\t});\n\t}\n\n\t/**\n\t * Remove a value from the consensus collection. If the collection is empty, returns false.\n\t * Otherwise calls callback with the value\n\t */\n\tpublic async acquire(callback: ConsensusCallback<T>): Promise<boolean> {\n\t\tconst result = await this.acquireInternal();\n\t\tif (result === undefined) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst res = await callback(result.value);\n\n\t\tswitch (res) {\n\t\t\tcase ConsensusResult.Complete: {\n\t\t\t\tawait this.complete(result.acquireId);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase ConsensusResult.Release: {\n\t\t\t\tthis.release(result.acquireId);\n\t\t\t\tthis.emit(\"localRelease\", result.value, true /* intentional */);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tunreachableCase(res);\n\t\t\t}\n\t\t}\n\n\t\treturn true;\n\t}\n\n\t/**\n\t * Wait for a value to be available and acquire it from the consensus collection\n\t */\n\tpublic async waitAndAcquire(callback: ConsensusCallback<T>): Promise<void> {\n\t\tdo {\n\t\t\tif (this.data.size() === 0) {\n\t\t\t\t// Wait for new entry before trying to acquire again\n\t\t\t\tawait this.newAckBasedPromise<T>((resolve) => {\n\t\t\t\t\tthis.once(\"add\", resolve);\n\t\t\t\t});\n\t\t\t}\n\t\t} while (!(await this.acquire(callback)));\n\t}\n\n\tprotected summarizeCore(serializer: IFluidSerializer): ISummaryTreeWithStats {\n\t\t// If we are transitioning from unattached to attached mode,\n\t\t// then we are losing all checked out work!\n\t\tthis.removeClient(idForLocalUnattachedClient);\n\n\t\tconst builder = new SummaryTreeBuilder();\n\t\tlet blobContent = this.serializeValue(this.data.asArray(), serializer);\n\t\tbuilder.addBlob(snapshotFileNameData, blobContent);\n\t\tblobContent = this.serializeValue([...this.jobTracking.entries()], serializer);\n\t\tbuilder.addBlob(snapshotFileNameTracking, blobContent);\n\t\treturn builder.getSummaryTree();\n\t}\n\n\tprotected isActive(): boolean {\n\t\treturn this.runtime.connected && this.deltaManager.active;\n\t}\n\n\tprotected async complete(acquireId: string): Promise<void> {\n\t\tif (!this.isAttached()) {\n\t\t\tthis.completeCore(acquireId);\n\t\t\treturn;\n\t\t}\n\n\t\t// if not active, this item already was released to queue (as observed by other clients)\n\t\tif (this.isActive()) {\n\t\t\tawait this.submit<IConsensusOrderedCollectionCompleteOperation>({\n\t\t\t\topName: \"complete\",\n\t\t\t\tacquireId,\n\t\t\t});\n\t\t}\n\t}\n\n\tprotected completeCore(acquireId: string): void {\n\t\t// Note: item may be no longer in jobTracking and returned back to queue!\n\t\tconst rec = this.jobTracking.get(acquireId);\n\t\tif (rec !== undefined) {\n\t\t\tthis.jobTracking.delete(acquireId);\n\t\t\tthis.emit(\"complete\", rec.value);\n\t\t}\n\t}\n\n\tprotected release(acquireId: string): void {\n\t\tif (!this.isAttached()) {\n\t\t\tthis.releaseCore(acquireId);\n\t\t\treturn;\n\t\t}\n\n\t\t// if not active, this item already was released to queue (as observed by other clients)\n\t\tif (this.isActive()) {\n\t\t\tthis.submit<IConsensusOrderedCollectionReleaseOperation>({\n\t\t\t\topName: \"release\",\n\t\t\t\tacquireId,\n\t\t\t}).catch((error) => {\n\t\t\t\tthis.logger.sendErrorEvent({ eventName: \"ConsensusQueue_release\" }, error);\n\t\t\t});\n\t\t}\n\t}\n\n\tprotected releaseCore(acquireId: string): void {\n\t\t// Note: item may be no longer in jobTracking and returned back to queue!\n\t\tconst rec = this.jobTracking.get(acquireId);\n\t\tif (rec !== undefined) {\n\t\t\tthis.jobTracking.delete(acquireId);\n\t\t\tthis.data.add(rec.value);\n\t\t\tthis.emit(\"add\", rec.value, false /* newlyAdded */);\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}\n\t */\n\tprotected async loadCore(storage: IChannelStorageService): Promise<void> {\n\t\tassert(\n\t\t\tthis.jobTracking.size === 0,\n\t\t\t0x068 /* \"On consensusOrderedCollection load, job tracking size > 0\" */,\n\t\t);\n\t\tconst blob = await storage.readBlob(snapshotFileNameTracking);\n\t\tconst rawContentTracking = bufferToString(blob, \"utf8\");\n\t\tconst content = this.deserializeValue(rawContentTracking, this.serializer);\n\t\tthis.jobTracking = new Map(\n\t\t\tcontent as Iterable<[string, { value: T; clientId: string | undefined }]>,\n\t\t);\n\n\t\tassert(\n\t\t\tthis.data.size() === 0,\n\t\t\t0x069 /* \"On consensusOrderedCollection load, data size > 0\" */,\n\t\t);\n\t\tconst blob2 = await storage.readBlob(snapshotFileNameData);\n\t\tconst rawContentData = bufferToString(blob2, \"utf8\");\n\t\tconst content2 = this.deserializeValue(rawContentData, this.serializer) as T[];\n\t\tthis.data.loadFrom(content2);\n\t}\n\n\tprotected onDisconnect(): void {\n\t\tfor (const [, { value, clientId }] of this.jobTracking) {\n\t\t\tif (clientId === this.runtime.clientId) {\n\t\t\t\tthis.emit(\"localRelease\", value, false /* intentional */);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.processMessagesCore}\n\t */\n\tprotected processMessagesCore(messagesCollection: IRuntimeMessageCollection): void {\n\t\tconst { envelope, local, messagesContent } = messagesCollection;\n\t\tfor (const messageContent of messagesContent) {\n\t\t\tthis.processMessage(envelope, messageContent, local);\n\t\t}\n\t}\n\n\tprivate processMessage(\n\t\tmessageEnvelope: ISequencedMessageEnvelope,\n\t\tmessageContent: IRuntimeMessagesContent,\n\t\tlocal: boolean,\n\t): void {\n\t\tif (messageEnvelope.type === MessageType.Operation) {\n\t\t\tconst op = messageContent.contents as IConsensusOrderedCollectionOperation<T>;\n\t\t\tlet value: IConsensusOrderedCollectionValue<T> | undefined;\n\t\t\tswitch (op.opName) {\n\t\t\t\tcase \"add\": {\n\t\t\t\t\tif (op.deserializedValue === undefined) {\n\t\t\t\t\t\tthis.addCore(this.deserializeValue(op.value, this.serializer) as T);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.addCore(op.deserializedValue);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase \"acquire\": {\n\t\t\t\t\tvalue = this.acquireCore(op.acquireId, messageEnvelope.clientId ?? undefined);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase \"complete\": {\n\t\t\t\t\tthis.completeCore(op.acquireId);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase \"release\": {\n\t\t\t\t\tthis.releaseCore(op.acquireId);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tdefault: {\n\t\t\t\t\tunreachableCase(op);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (local) {\n\t\t\t\t// Resolve the pending promise for this operation now that we have received an ack for it.\n\t\t\t\tconst resolve = messageContent.localOpMetadata as PendingResolve<T>;\n\t\t\t\tresolve(value);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate async submit<TMessage extends IConsensusOrderedCollectionOperation<T>>(\n\t\tmessage: TMessage,\n\t): Promise<IConsensusOrderedCollectionValue<T> | undefined> {\n\t\tassert(this.isAttached(), 0x06a /* \"Trying to submit message while detached!\" */);\n\n\t\treturn this.newAckBasedPromise<IConsensusOrderedCollectionValue<T> | undefined>(\n\t\t\t(resolve) => {\n\t\t\t\t// Send the resolve function as the localOpMetadata. This will be provided back to us when the\n\t\t\t\t// op is ack'd.\n\t\t\t\tthis.submitLocalMessage(message, resolve);\n\t\t\t\t// If we fail due to runtime being disposed, it's better to return undefined then unhandled exception.\n\t\t\t},\n\t\t).catch((error) => undefined);\n\t}\n\n\tprivate addCore(value: T): void {\n\t\tthis.data.add(value);\n\t\tthis.emit(\"add\", value, true /* newlyAdded */);\n\t}\n\n\tprivate acquireCore(\n\t\tacquireId: string,\n\t\tclientId?: string,\n\t): IConsensusOrderedCollectionValue<T> | undefined {\n\t\tif (this.data.size() === 0) {\n\t\t\treturn undefined;\n\t\t}\n\t\tconst value = this.data.remove();\n\n\t\tconst value2: IConsensusOrderedCollectionValue<T> = {\n\t\t\tacquireId,\n\t\t\tvalue,\n\t\t};\n\t\tthis.jobTracking.set(value2.acquireId, { value, clientId });\n\n\t\tthis.emit(\"acquire\", value, clientId);\n\t\treturn value2;\n\t}\n\n\tprivate async acquireInternal(): Promise<IConsensusOrderedCollectionValue<T> | undefined> {\n\t\tif (!this.isAttached()) {\n\t\t\t// can be undefined if queue is empty\n\t\t\treturn this.acquireCore(uuid(), idForLocalUnattachedClient);\n\t\t}\n\n\t\treturn this.submit<IConsensusOrderedCollectionAcquireOperation>({\n\t\t\topName: \"acquire\",\n\t\t\tacquireId: uuid(),\n\t\t});\n\t}\n\n\tprivate removeClient(clientIdToRemove?: string): void {\n\t\tconst added: T[] = [];\n\t\tfor (const [acquireId, { value, clientId }] of this.jobTracking) {\n\t\t\tif (clientId === clientIdToRemove) {\n\t\t\t\tthis.jobTracking.delete(acquireId);\n\t\t\t\tthis.data.add(value);\n\t\t\t\tadded.push(value);\n\t\t\t}\n\t\t}\n\n\t\t// Raise all events only after all state changes are completed,\n\t\t// to guarantee same ordering of operations if collection is manipulated from events.\n\t\tadded.map((value) => this.emit(\"add\", value, false /* newlyAdded */));\n\t}\n\n\tprivate serializeValue(value, serializer: IFluidSerializer): string {\n\t\treturn serializer.stringify(value, this.handle);\n\t}\n\n\tprivate deserializeValue(content: string, serializer: IFluidSerializer): unknown {\n\t\treturn serializer.parse(content);\n\t}\n\n\tprotected applyStashedOp(): void {\n\t\tthrow new Error(\"not implemented\");\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.rollback}\n\t * @sealed\n\t */\n\tprotected rollback(content: unknown, localOpMetadata: unknown): void {\n\t\tassert(\n\t\t\ttypeof localOpMetadata === \"function\",\n\t\t\t0xc93 /* localOpMetadata should be a function */,\n\t\t);\n\t\t// A resolve function is passed as the localOpMetadata on this.submitLocalMessage().\n\t\t// On rollback we resolve with undefined and the promises will handle it appropriately.\n\t\tconst resolve = localOpMetadata as PendingResolve<T>;\n\t\tresolve(undefined);\n\t}\n}\n"]}
|
package/lib/index.d.ts
CHANGED
|
@@ -6,5 +6,5 @@ export { type ConsensusCallback, ConsensusResult, type IConsensusOrderedCollecti
|
|
|
6
6
|
export { ConsensusQueueFactory, ConsensusQueue } from "./consensusOrderedCollectionFactory.js";
|
|
7
7
|
export { ConsensusOrderedCollection } from "./consensusOrderedCollection.js";
|
|
8
8
|
export { ConsensusQueueClass } from "./consensusQueue.js";
|
|
9
|
-
export { acquireAndComplete, waitAcquireAndComplete } from "./testUtils.js";
|
|
9
|
+
export { acquireAndComplete, waitAcquireAndComplete, acquireAndRelease, waitAcquireAndRelease, } from "./testUtils.js";
|
|
10
10
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,KAAK,iBAAiB,EACtB,eAAe,EACf,KAAK,2BAA2B,EAChC,KAAK,iCAAiC,EACtC,KAAK,kCAAkC,EACvC,KAAK,kBAAkB,EACvB,KAAK,aAAa,GAClB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AAC/F,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,KAAK,iBAAiB,EACtB,eAAe,EACf,KAAK,2BAA2B,EAChC,KAAK,iCAAiC,EACtC,KAAK,kCAAkC,EACvC,KAAK,kBAAkB,EACvB,KAAK,aAAa,GAClB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AAC/F,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EACN,kBAAkB,EAClB,sBAAsB,EACtB,iBAAiB,EACjB,qBAAqB,GACrB,MAAM,gBAAgB,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -6,5 +6,5 @@ export { ConsensusResult, } from "./interfaces.js";
|
|
|
6
6
|
export { ConsensusQueueFactory, ConsensusQueue } from "./consensusOrderedCollectionFactory.js";
|
|
7
7
|
export { ConsensusOrderedCollection } from "./consensusOrderedCollection.js";
|
|
8
8
|
export { ConsensusQueueClass } from "./consensusQueue.js";
|
|
9
|
-
export { acquireAndComplete, waitAcquireAndComplete } from "./testUtils.js";
|
|
9
|
+
export { acquireAndComplete, waitAcquireAndComplete, acquireAndRelease, waitAcquireAndRelease, } from "./testUtils.js";
|
|
10
10
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAEN,eAAe,GAMf,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AAC/F,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAEN,eAAe,GAMf,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AAC/F,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EACN,kBAAkB,EAClB,sBAAsB,EACtB,iBAAiB,EACjB,qBAAqB,GACrB,MAAM,gBAAgB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\ttype ConsensusCallback,\n\tConsensusResult,\n\ttype IConsensusOrderedCollection,\n\ttype IConsensusOrderedCollectionEvents,\n\ttype IConsensusOrderedCollectionFactory,\n\ttype IOrderedCollection,\n\ttype ISnapshotable,\n} from \"./interfaces.js\";\nexport { ConsensusQueueFactory, ConsensusQueue } from \"./consensusOrderedCollectionFactory.js\";\nexport { ConsensusOrderedCollection } from \"./consensusOrderedCollection.js\";\nexport { ConsensusQueueClass } from \"./consensusQueue.js\";\nexport {\n\tacquireAndComplete,\n\twaitAcquireAndComplete,\n\tacquireAndRelease,\n\twaitAcquireAndRelease,\n} from \"./testUtils.js\";\n"]}
|
package/lib/packageVersion.d.ts
CHANGED
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
|
|
6
6
|
*/
|
|
7
7
|
export declare const pkgName = "@fluidframework/ordered-collection";
|
|
8
|
-
export declare const pkgVersion = "2.
|
|
8
|
+
export declare const pkgVersion = "2.71.0";
|
|
9
9
|
//# sourceMappingURL=packageVersion.d.ts.map
|
package/lib/packageVersion.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,oCAAoC,CAAC;AAC5D,MAAM,CAAC,MAAM,UAAU,GAAG,QAAQ,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/ordered-collection\";\nexport const pkgVersion = \"2.
|
|
1
|
+
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,oCAAoC,CAAC;AAC5D,MAAM,CAAC,MAAM,UAAU,GAAG,QAAQ,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/ordered-collection\";\nexport const pkgVersion = \"2.71.0\";\n"]}
|
package/lib/testUtils.d.ts
CHANGED
|
@@ -15,4 +15,16 @@ export declare function acquireAndComplete<T>(collection: IConsensusOrderedColle
|
|
|
15
15
|
* @internal
|
|
16
16
|
*/
|
|
17
17
|
export declare function waitAcquireAndComplete<T>(collection: IConsensusOrderedCollection<T>): Promise<T>;
|
|
18
|
+
/**
|
|
19
|
+
* Helper method to acquire and release an item
|
|
20
|
+
* Should be used in test code only
|
|
21
|
+
* @internal
|
|
22
|
+
*/
|
|
23
|
+
export declare function acquireAndRelease<T>(collection: IConsensusOrderedCollection<T>): Promise<T | undefined>;
|
|
24
|
+
/**
|
|
25
|
+
* Helper method to acquire and release an item
|
|
26
|
+
* Should be used in test code only
|
|
27
|
+
* @internal
|
|
28
|
+
*/
|
|
29
|
+
export declare function waitAcquireAndRelease<T>(collection: IConsensusOrderedCollection<T>): Promise<T>;
|
|
18
30
|
//# sourceMappingURL=testUtils.d.ts.map
|
package/lib/testUtils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testUtils.d.ts","sourceRoot":"","sources":["../src/testUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAmB,KAAK,2BAA2B,EAAE,MAAM,iBAAiB,CAAC;AAEpF;;;;GAIG;AACH,wBAAsB,kBAAkB,CAAC,CAAC,EACzC,UAAU,EAAE,2BAA2B,CAAC,CAAC,CAAC,GACxC,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,CAOxB;AAED;;;;GAIG;AACH,wBAAsB,sBAAsB,CAAC,CAAC,EAC7C,UAAU,EAAE,2BAA2B,CAAC,CAAC,CAAC,GACxC,OAAO,CAAC,CAAC,CAAC,CAOZ"}
|
|
1
|
+
{"version":3,"file":"testUtils.d.ts","sourceRoot":"","sources":["../src/testUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAmB,KAAK,2BAA2B,EAAE,MAAM,iBAAiB,CAAC;AAEpF;;;;GAIG;AACH,wBAAsB,kBAAkB,CAAC,CAAC,EACzC,UAAU,EAAE,2BAA2B,CAAC,CAAC,CAAC,GACxC,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,CAOxB;AAED;;;;GAIG;AACH,wBAAsB,sBAAsB,CAAC,CAAC,EAC7C,UAAU,EAAE,2BAA2B,CAAC,CAAC,CAAC,GACxC,OAAO,CAAC,CAAC,CAAC,CAOZ;AAED;;;;GAIG;AACH,wBAAsB,iBAAiB,CAAC,CAAC,EACxC,UAAU,EAAE,2BAA2B,CAAC,CAAC,CAAC,GACxC,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,CAOxB;AAED;;;;GAIG;AACH,wBAAsB,qBAAqB,CAAC,CAAC,EAC5C,UAAU,EAAE,2BAA2B,CAAC,CAAC,CAAC,GACxC,OAAO,CAAC,CAAC,CAAC,CAOZ"}
|
package/lib/testUtils.js
CHANGED
|
@@ -29,4 +29,30 @@ export async function waitAcquireAndComplete(collection) {
|
|
|
29
29
|
});
|
|
30
30
|
return res;
|
|
31
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* Helper method to acquire and release an item
|
|
34
|
+
* Should be used in test code only
|
|
35
|
+
* @internal
|
|
36
|
+
*/
|
|
37
|
+
export async function acquireAndRelease(collection) {
|
|
38
|
+
let res;
|
|
39
|
+
await collection.acquire(async (value) => {
|
|
40
|
+
res = value;
|
|
41
|
+
return ConsensusResult.Release;
|
|
42
|
+
});
|
|
43
|
+
return res;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Helper method to acquire and release an item
|
|
47
|
+
* Should be used in test code only
|
|
48
|
+
* @internal
|
|
49
|
+
*/
|
|
50
|
+
export async function waitAcquireAndRelease(collection) {
|
|
51
|
+
let res;
|
|
52
|
+
await collection.waitAndAcquire(async (value) => {
|
|
53
|
+
res = value;
|
|
54
|
+
return ConsensusResult.Release;
|
|
55
|
+
});
|
|
56
|
+
return res;
|
|
57
|
+
}
|
|
32
58
|
//# sourceMappingURL=testUtils.js.map
|
package/lib/testUtils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testUtils.js","sourceRoot":"","sources":["../src/testUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,eAAe,EAAoC,MAAM,iBAAiB,CAAC;AAEpF;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACvC,UAA0C;IAE1C,IAAI,GAAkB,CAAC;IACvB,MAAM,UAAU,CAAC,OAAO,CAAC,KAAK,EAAE,KAAQ,EAAE,EAAE;QAC3C,GAAG,GAAG,KAAK,CAAC;QACZ,OAAO,eAAe,CAAC,QAAQ,CAAC;IACjC,CAAC,CAAC,CAAC;IACH,OAAO,GAAG,CAAC;AACZ,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC3C,UAA0C;IAE1C,IAAI,GAAkB,CAAC;IACvB,MAAM,UAAU,CAAC,cAAc,CAAC,KAAK,EAAE,KAAQ,EAAE,EAAE;QAClD,GAAG,GAAG,KAAK,CAAC;QACZ,OAAO,eAAe,CAAC,QAAQ,CAAC;IACjC,CAAC,CAAC,CAAC;IACH,OAAO,GAAQ,CAAC;AACjB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ConsensusResult, type IConsensusOrderedCollection } from \"./interfaces.js\";\n\n/**\n * Helper method to acquire and complete an item\n * Should be used in test code only\n * @internal\n */\nexport async function acquireAndComplete<T>(\n\tcollection: IConsensusOrderedCollection<T>,\n): Promise<T | undefined> {\n\tlet res: T | undefined;\n\tawait collection.acquire(async (value: T) => {\n\t\tres = value;\n\t\treturn ConsensusResult.Complete;\n\t});\n\treturn res;\n}\n\n/**\n * Helper method to acquire and complete an item\n * Should be used in test code only\n * @internal\n */\nexport async function waitAcquireAndComplete<T>(\n\tcollection: IConsensusOrderedCollection<T>,\n): Promise<T> {\n\tlet res: T | undefined;\n\tawait collection.waitAndAcquire(async (value: T) => {\n\t\tres = value;\n\t\treturn ConsensusResult.Complete;\n\t});\n\treturn res as T;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"testUtils.js","sourceRoot":"","sources":["../src/testUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,eAAe,EAAoC,MAAM,iBAAiB,CAAC;AAEpF;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACvC,UAA0C;IAE1C,IAAI,GAAkB,CAAC;IACvB,MAAM,UAAU,CAAC,OAAO,CAAC,KAAK,EAAE,KAAQ,EAAE,EAAE;QAC3C,GAAG,GAAG,KAAK,CAAC;QACZ,OAAO,eAAe,CAAC,QAAQ,CAAC;IACjC,CAAC,CAAC,CAAC;IACH,OAAO,GAAG,CAAC;AACZ,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC3C,UAA0C;IAE1C,IAAI,GAAkB,CAAC;IACvB,MAAM,UAAU,CAAC,cAAc,CAAC,KAAK,EAAE,KAAQ,EAAE,EAAE;QAClD,GAAG,GAAG,KAAK,CAAC;QACZ,OAAO,eAAe,CAAC,QAAQ,CAAC;IACjC,CAAC,CAAC,CAAC;IACH,OAAO,GAAQ,CAAC;AACjB,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACtC,UAA0C;IAE1C,IAAI,GAAkB,CAAC;IACvB,MAAM,UAAU,CAAC,OAAO,CAAC,KAAK,EAAE,KAAQ,EAAE,EAAE;QAC3C,GAAG,GAAG,KAAK,CAAC;QACZ,OAAO,eAAe,CAAC,OAAO,CAAC;IAChC,CAAC,CAAC,CAAC;IACH,OAAO,GAAG,CAAC;AACZ,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAC1C,UAA0C;IAE1C,IAAI,GAAkB,CAAC;IACvB,MAAM,UAAU,CAAC,cAAc,CAAC,KAAK,EAAE,KAAQ,EAAE,EAAE;QAClD,GAAG,GAAG,KAAK,CAAC;QACZ,OAAO,eAAe,CAAC,OAAO,CAAC;IAChC,CAAC,CAAC,CAAC;IACH,OAAO,GAAQ,CAAC;AACjB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ConsensusResult, type IConsensusOrderedCollection } from \"./interfaces.js\";\n\n/**\n * Helper method to acquire and complete an item\n * Should be used in test code only\n * @internal\n */\nexport async function acquireAndComplete<T>(\n\tcollection: IConsensusOrderedCollection<T>,\n): Promise<T | undefined> {\n\tlet res: T | undefined;\n\tawait collection.acquire(async (value: T) => {\n\t\tres = value;\n\t\treturn ConsensusResult.Complete;\n\t});\n\treturn res;\n}\n\n/**\n * Helper method to acquire and complete an item\n * Should be used in test code only\n * @internal\n */\nexport async function waitAcquireAndComplete<T>(\n\tcollection: IConsensusOrderedCollection<T>,\n): Promise<T> {\n\tlet res: T | undefined;\n\tawait collection.waitAndAcquire(async (value: T) => {\n\t\tres = value;\n\t\treturn ConsensusResult.Complete;\n\t});\n\treturn res as T;\n}\n\n/**\n * Helper method to acquire and release an item\n * Should be used in test code only\n * @internal\n */\nexport async function acquireAndRelease<T>(\n\tcollection: IConsensusOrderedCollection<T>,\n): Promise<T | undefined> {\n\tlet res: T | undefined;\n\tawait collection.acquire(async (value: T) => {\n\t\tres = value;\n\t\treturn ConsensusResult.Release;\n\t});\n\treturn res;\n}\n\n/**\n * Helper method to acquire and release an item\n * Should be used in test code only\n * @internal\n */\nexport async function waitAcquireAndRelease<T>(\n\tcollection: IConsensusOrderedCollection<T>,\n): Promise<T> {\n\tlet res: T | undefined;\n\tawait collection.waitAndAcquire(async (value: T) => {\n\t\tres = value;\n\t\treturn ConsensusResult.Release;\n\t});\n\treturn res as T;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/ordered-collection",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.71.0",
|
|
4
4
|
"description": "Consensus Collection",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -69,28 +69,28 @@
|
|
|
69
69
|
"temp-directory": "nyc/.nyc_output"
|
|
70
70
|
},
|
|
71
71
|
"dependencies": {
|
|
72
|
-
"@fluid-internal/client-utils": "~2.
|
|
73
|
-
"@fluidframework/core-interfaces": "~2.
|
|
74
|
-
"@fluidframework/core-utils": "~2.
|
|
75
|
-
"@fluidframework/datastore-definitions": "~2.
|
|
76
|
-
"@fluidframework/driver-definitions": "~2.
|
|
77
|
-
"@fluidframework/runtime-definitions": "~2.
|
|
78
|
-
"@fluidframework/runtime-utils": "~2.
|
|
79
|
-
"@fluidframework/shared-object-base": "~2.
|
|
80
|
-
"@fluidframework/telemetry-utils": "~2.
|
|
72
|
+
"@fluid-internal/client-utils": "~2.71.0",
|
|
73
|
+
"@fluidframework/core-interfaces": "~2.71.0",
|
|
74
|
+
"@fluidframework/core-utils": "~2.71.0",
|
|
75
|
+
"@fluidframework/datastore-definitions": "~2.71.0",
|
|
76
|
+
"@fluidframework/driver-definitions": "~2.71.0",
|
|
77
|
+
"@fluidframework/runtime-definitions": "~2.71.0",
|
|
78
|
+
"@fluidframework/runtime-utils": "~2.71.0",
|
|
79
|
+
"@fluidframework/shared-object-base": "~2.71.0",
|
|
80
|
+
"@fluidframework/telemetry-utils": "~2.71.0",
|
|
81
81
|
"uuid": "^11.1.0"
|
|
82
82
|
},
|
|
83
83
|
"devDependencies": {
|
|
84
84
|
"@arethetypeswrong/cli": "^0.17.1",
|
|
85
85
|
"@biomejs/biome": "~1.9.3",
|
|
86
|
-
"@fluid-internal/mocha-test-setup": "~2.
|
|
87
|
-
"@fluid-private/test-dds-utils": "~2.
|
|
86
|
+
"@fluid-internal/mocha-test-setup": "~2.71.0",
|
|
87
|
+
"@fluid-private/test-dds-utils": "~2.71.0",
|
|
88
88
|
"@fluid-tools/build-cli": "^0.58.3",
|
|
89
89
|
"@fluidframework/build-common": "^2.0.3",
|
|
90
90
|
"@fluidframework/build-tools": "^0.58.3",
|
|
91
|
-
"@fluidframework/eslint-config-fluid": "^
|
|
92
|
-
"@fluidframework/ordered-collection-previous": "npm:@fluidframework/ordered-collection@2.
|
|
93
|
-
"@fluidframework/test-runtime-utils": "~2.
|
|
91
|
+
"@fluidframework/eslint-config-fluid": "^7.0.0",
|
|
92
|
+
"@fluidframework/ordered-collection-previous": "npm:@fluidframework/ordered-collection@2.70.0",
|
|
93
|
+
"@fluidframework/test-runtime-utils": "~2.71.0",
|
|
94
94
|
"@microsoft/api-extractor": "7.52.11",
|
|
95
95
|
"@types/mocha": "^10.0.10",
|
|
96
96
|
"@types/node": "^18.19.0",
|
|
@@ -138,8 +138,8 @@
|
|
|
138
138
|
"ci:build:api-reports:legacy": "api-extractor run --config api-extractor/api-extractor.legacy.json",
|
|
139
139
|
"ci:build:docs": "api-extractor run",
|
|
140
140
|
"clean": "rimraf --glob dist lib {alpha,beta,internal,legacy}.d.ts \"**/*.tsbuildinfo\" \"**/*.build.log\" _api-extractor-temp nyc",
|
|
141
|
-
"eslint": "eslint --format stylish src",
|
|
142
|
-
"eslint:fix": "eslint --format stylish src --fix --fix-type problem,suggestion,layout",
|
|
141
|
+
"eslint": "eslint --quiet --format stylish src",
|
|
142
|
+
"eslint:fix": "eslint --quiet --format stylish src --fix --fix-type problem,suggestion,layout",
|
|
143
143
|
"format": "npm run format:biome",
|
|
144
144
|
"format:biome": "biome check . --write",
|
|
145
145
|
"lint": "fluid-build . --task lint",
|
|
@@ -436,4 +436,19 @@ export class ConsensusOrderedCollection<T = any>
|
|
|
436
436
|
protected applyStashedOp(): void {
|
|
437
437
|
throw new Error("not implemented");
|
|
438
438
|
}
|
|
439
|
+
|
|
440
|
+
/**
|
|
441
|
+
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.rollback}
|
|
442
|
+
* @sealed
|
|
443
|
+
*/
|
|
444
|
+
protected rollback(content: unknown, localOpMetadata: unknown): void {
|
|
445
|
+
assert(
|
|
446
|
+
typeof localOpMetadata === "function",
|
|
447
|
+
0xc93 /* localOpMetadata should be a function */,
|
|
448
|
+
);
|
|
449
|
+
// A resolve function is passed as the localOpMetadata on this.submitLocalMessage().
|
|
450
|
+
// On rollback we resolve with undefined and the promises will handle it appropriately.
|
|
451
|
+
const resolve = localOpMetadata as PendingResolve<T>;
|
|
452
|
+
resolve(undefined);
|
|
453
|
+
}
|
|
439
454
|
}
|
package/src/index.ts
CHANGED
|
@@ -15,4 +15,9 @@ export {
|
|
|
15
15
|
export { ConsensusQueueFactory, ConsensusQueue } from "./consensusOrderedCollectionFactory.js";
|
|
16
16
|
export { ConsensusOrderedCollection } from "./consensusOrderedCollection.js";
|
|
17
17
|
export { ConsensusQueueClass } from "./consensusQueue.js";
|
|
18
|
-
export {
|
|
18
|
+
export {
|
|
19
|
+
acquireAndComplete,
|
|
20
|
+
waitAcquireAndComplete,
|
|
21
|
+
acquireAndRelease,
|
|
22
|
+
waitAcquireAndRelease,
|
|
23
|
+
} from "./testUtils.js";
|
package/src/packageVersion.ts
CHANGED
package/src/testUtils.ts
CHANGED
|
@@ -36,3 +36,35 @@ export async function waitAcquireAndComplete<T>(
|
|
|
36
36
|
});
|
|
37
37
|
return res as T;
|
|
38
38
|
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Helper method to acquire and release an item
|
|
42
|
+
* Should be used in test code only
|
|
43
|
+
* @internal
|
|
44
|
+
*/
|
|
45
|
+
export async function acquireAndRelease<T>(
|
|
46
|
+
collection: IConsensusOrderedCollection<T>,
|
|
47
|
+
): Promise<T | undefined> {
|
|
48
|
+
let res: T | undefined;
|
|
49
|
+
await collection.acquire(async (value: T) => {
|
|
50
|
+
res = value;
|
|
51
|
+
return ConsensusResult.Release;
|
|
52
|
+
});
|
|
53
|
+
return res;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Helper method to acquire and release an item
|
|
58
|
+
* Should be used in test code only
|
|
59
|
+
* @internal
|
|
60
|
+
*/
|
|
61
|
+
export async function waitAcquireAndRelease<T>(
|
|
62
|
+
collection: IConsensusOrderedCollection<T>,
|
|
63
|
+
): Promise<T> {
|
|
64
|
+
let res: T | undefined;
|
|
65
|
+
await collection.waitAndAcquire(async (value: T) => {
|
|
66
|
+
res = value;
|
|
67
|
+
return ConsensusResult.Release;
|
|
68
|
+
});
|
|
69
|
+
return res as T;
|
|
70
|
+
}
|