@fluid-experimental/attributor 2.1.0 → 2.3.0-288113
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/README.md +2 -2
- package/dist/attributorContracts.d.ts +49 -0
- package/dist/attributorContracts.d.ts.map +1 -0
- package/dist/attributorContracts.js +22 -0
- package/dist/attributorContracts.js.map +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -4
- package/dist/index.js.map +1 -1
- package/dist/mixinAttributor.d.ts +8 -49
- package/dist/mixinAttributor.d.ts.map +1 -1
- package/dist/mixinAttributor.js +35 -140
- package/dist/mixinAttributor.js.map +1 -1
- package/dist/runtimeAttributor.d.ts +19 -0
- package/dist/runtimeAttributor.d.ts.map +1 -0
- package/dist/runtimeAttributor.js +71 -0
- package/dist/runtimeAttributor.js.map +1 -0
- package/dist/runtimeAttributorDataStoreChannel.d.ts +92 -0
- package/dist/runtimeAttributorDataStoreChannel.d.ts.map +1 -0
- package/dist/runtimeAttributorDataStoreChannel.js +177 -0
- package/dist/runtimeAttributorDataStoreChannel.js.map +1 -0
- package/dist/runtimeAttributorDataStoreFactory.d.ts +15 -0
- package/dist/runtimeAttributorDataStoreFactory.d.ts.map +1 -0
- package/dist/runtimeAttributorDataStoreFactory.js +39 -0
- package/dist/runtimeAttributorDataStoreFactory.js.map +1 -0
- package/lib/attributorContracts.d.ts +49 -0
- package/lib/attributorContracts.d.ts.map +1 -0
- package/lib/attributorContracts.js +19 -0
- package/lib/attributorContracts.js.map +1 -0
- package/lib/index.d.ts +2 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -1
- package/lib/index.js.map +1 -1
- package/lib/mixinAttributor.d.ts +8 -49
- package/lib/mixinAttributor.d.ts.map +1 -1
- package/lib/mixinAttributor.js +33 -138
- package/lib/mixinAttributor.js.map +1 -1
- package/lib/runtimeAttributor.d.ts +19 -0
- package/lib/runtimeAttributor.d.ts.map +1 -0
- package/lib/runtimeAttributor.js +67 -0
- package/lib/runtimeAttributor.js.map +1 -0
- package/lib/runtimeAttributorDataStoreChannel.d.ts +92 -0
- package/lib/runtimeAttributorDataStoreChannel.d.ts.map +1 -0
- package/lib/runtimeAttributorDataStoreChannel.js +173 -0
- package/lib/runtimeAttributorDataStoreChannel.js.map +1 -0
- package/lib/runtimeAttributorDataStoreFactory.d.ts +15 -0
- package/lib/runtimeAttributorDataStoreFactory.d.ts.map +1 -0
- package/lib/runtimeAttributorDataStoreFactory.js +35 -0
- package/lib/runtimeAttributorDataStoreFactory.js.map +1 -0
- package/package.json +20 -19
- package/src/attributorContracts.ts +61 -0
- package/src/index.ts +3 -3
- package/src/mixinAttributor.ts +45 -267
- package/src/runtimeAttributor.ts +111 -0
- package/src/runtimeAttributorDataStoreChannel.ts +261 -0
- package/src/runtimeAttributorDataStoreFactory.ts +59 -0
package/lib/mixinAttributor.js
CHANGED
|
@@ -2,58 +2,39 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import { bufferToString } from "@fluid-internal/client-utils";
|
|
6
5
|
import { ContainerRuntime } from "@fluidframework/container-runtime/internal";
|
|
7
|
-
import { assert
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import { AttributorSerializer, chain, deltaEncoder } from "./encoders.js";
|
|
12
|
-
import { makeLZ4Encoder } from "./lz4Encoder.js";
|
|
13
|
-
// Summary tree keys
|
|
14
|
-
const attributorTreeName = ".attributor";
|
|
15
|
-
const opBlobName = "op";
|
|
6
|
+
import { assert } from "@fluidframework/core-utils/internal";
|
|
7
|
+
import { loggerToMonitoringContext } from "@fluidframework/telemetry-utils/internal";
|
|
8
|
+
import { attributorDataStoreAlias, enableOnNewFileKey, } from "./attributorContracts.js";
|
|
9
|
+
import { RuntimeAttributorFactory } from "./runtimeAttributorDataStoreFactory.js";
|
|
16
10
|
/**
|
|
11
|
+
* Utility function to get the runtime attributor from the container runtime.
|
|
12
|
+
* @param runtime - container runtime from which attributor is to be fetched.
|
|
13
|
+
* @returns IRuntimeAttributor if it exists, otherwise undefined.
|
|
17
14
|
* @internal
|
|
18
15
|
*/
|
|
19
|
-
export
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
export const IRuntimeAttributor = "IRuntimeAttributor";
|
|
24
|
-
/**
|
|
25
|
-
* Creates an `IRuntimeAttributor` for usage with {@link mixinAttributor}.
|
|
26
|
-
*
|
|
27
|
-
* @remarks The attributor will only be populated with data once it's passed via scope to a container runtime load flow.
|
|
28
|
-
*
|
|
29
|
-
* @internal
|
|
30
|
-
*/
|
|
31
|
-
export function createRuntimeAttributor() {
|
|
32
|
-
return new RuntimeAttributor();
|
|
16
|
+
export async function getRuntimeAttributor(runtime) {
|
|
17
|
+
const entryPoint = await runtime.getAliasedDataStoreEntryPoint(attributorDataStoreAlias);
|
|
18
|
+
const runtimeAttributor = (await entryPoint?.get());
|
|
19
|
+
return runtimeAttributor?.IRuntimeAttributor;
|
|
33
20
|
}
|
|
34
21
|
/**
|
|
35
22
|
* Mixes in logic to load and store runtime-based attribution functionality.
|
|
36
23
|
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
* Existing documents without stored attributors will not start storing attribution information: if an
|
|
40
|
-
* IRuntimeAttributor is passed via scope to load a document that never previously had attribution information,
|
|
41
|
-
* that attributor's `has` method will always return `false`.
|
|
24
|
+
* Existing documents without stored attributor will not start storing attribution information. We only create the attributor
|
|
25
|
+
* if its tracking is enabled and we are creating a new document.
|
|
42
26
|
* @param Base - base class, inherits from FluidAttributorRuntime
|
|
43
27
|
* @internal
|
|
44
28
|
*/
|
|
45
29
|
export const mixinAttributor = (Base = ContainerRuntime) => class ContainerRuntimeWithAttributor extends Base {
|
|
46
30
|
static async loadRuntime(params) {
|
|
47
31
|
const { context, registryEntries, existing, requestHandler, provideEntryPoint, runtimeOptions, containerScope, containerRuntimeCtor = ContainerRuntimeWithAttributor, } = params;
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
const { quorum, deltaManager, taggedLogger } = context;
|
|
55
|
-
assert(quorum !== undefined, 0x968 /* quorum must exist when instantiating attribution-providing runtime */);
|
|
56
|
-
const mc = loggerToMonitoringContext(taggedLogger);
|
|
32
|
+
const mc = loggerToMonitoringContext(context.taggedLogger);
|
|
33
|
+
const factory = new RuntimeAttributorFactory();
|
|
34
|
+
const registryEntriesCopy = [
|
|
35
|
+
...registryEntries,
|
|
36
|
+
[RuntimeAttributorFactory.type, Promise.resolve(factory)],
|
|
37
|
+
];
|
|
57
38
|
const shouldTrackAttribution = mc.config.getBoolean(enableOnNewFileKey) ?? false;
|
|
58
39
|
if (shouldTrackAttribution) {
|
|
59
40
|
const { options } = context;
|
|
@@ -63,115 +44,29 @@ export const mixinAttributor = (Base = ContainerRuntime) => class ContainerRunti
|
|
|
63
44
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
64
45
|
const runtime = (await Base.loadRuntime({
|
|
65
46
|
context,
|
|
66
|
-
registryEntries,
|
|
47
|
+
registryEntries: registryEntriesCopy,
|
|
67
48
|
requestHandler,
|
|
68
49
|
provideEntryPoint,
|
|
69
|
-
// ! This prop is needed for back-compat. Can be removed in 2.0.0-internal.8.0.0
|
|
70
|
-
initializeEntryPoint: provideEntryPoint,
|
|
71
50
|
runtimeOptions,
|
|
72
51
|
containerScope,
|
|
73
52
|
existing,
|
|
74
53
|
containerRuntimeCtor,
|
|
75
54
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
76
55
|
}));
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
await runtime.runtimeAttributor?.initialize(deltaManager, quorum, baseSnapshot, async (id) => runtime.storage.readBlob(id), shouldTrackAttribution);
|
|
90
|
-
event.end({
|
|
91
|
-
attributionEnabledInConfig: shouldTrackAttribution,
|
|
92
|
-
attributionEnabledInDoc: runtime.runtimeAttributor
|
|
93
|
-
? runtime.runtimeAttributor.isEnabled
|
|
94
|
-
: false,
|
|
95
|
-
});
|
|
96
|
-
});
|
|
97
|
-
return runtime;
|
|
98
|
-
}
|
|
99
|
-
addContainerStateToSummary(summaryTree, fullTree, trackState, telemetryContext) {
|
|
100
|
-
super.addContainerStateToSummary(summaryTree, fullTree, trackState, telemetryContext);
|
|
101
|
-
const attributorSummary = this.runtimeAttributor?.summarize();
|
|
102
|
-
if (attributorSummary) {
|
|
103
|
-
addSummarizeResultToSummary(summaryTree, attributorTreeName, attributorSummary);
|
|
56
|
+
let runtimeAttributor;
|
|
57
|
+
if (shouldTrackAttribution) {
|
|
58
|
+
if (existing) {
|
|
59
|
+
runtimeAttributor = await getRuntimeAttributor(runtime);
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
const datastore = await runtime.createDataStore(RuntimeAttributorFactory.type);
|
|
63
|
+
const result = await datastore.trySetAlias(attributorDataStoreAlias);
|
|
64
|
+
assert(result === "Success", 0xa1b /* Failed to set alias for attributor data store */);
|
|
65
|
+
runtimeAttributor = (await datastore.entryPoint.get());
|
|
66
|
+
assert(runtimeAttributor !== undefined, 0xa1c /* Attributor should be defined */);
|
|
67
|
+
}
|
|
104
68
|
}
|
|
69
|
+
return runtime;
|
|
105
70
|
}
|
|
106
71
|
};
|
|
107
|
-
class RuntimeAttributor {
|
|
108
|
-
constructor() {
|
|
109
|
-
this.encoder = {
|
|
110
|
-
encode: unreachableCase,
|
|
111
|
-
decode: unreachableCase,
|
|
112
|
-
};
|
|
113
|
-
this.isEnabled = false;
|
|
114
|
-
}
|
|
115
|
-
get IRuntimeAttributor() {
|
|
116
|
-
return this;
|
|
117
|
-
}
|
|
118
|
-
get(key) {
|
|
119
|
-
assert(this.opAttributor !== undefined, 0x509 /* RuntimeAttributor must be initialized before getAttributionInfo can be called */);
|
|
120
|
-
if (key.type === "detached") {
|
|
121
|
-
throw new Error("Attribution of detached keys is not yet supported.");
|
|
122
|
-
}
|
|
123
|
-
if (key.type === "local") {
|
|
124
|
-
// Note: we can *almost* orchestrate this correctly with internal-only changes by looking up the current
|
|
125
|
-
// client id in the audience. However, for read->write client transition, the container might have not yet
|
|
126
|
-
// received a client id. This is left as a TODO as it might be more easily solved once the detached case
|
|
127
|
-
// is settled (e.g. if it's reasonable for the host to know the current user information at container
|
|
128
|
-
// creation time, we could just use that here as well).
|
|
129
|
-
throw new Error("Attribution of local keys is not yet supported.");
|
|
130
|
-
}
|
|
131
|
-
return this.opAttributor.getAttributionInfo(key.seq);
|
|
132
|
-
}
|
|
133
|
-
has(key) {
|
|
134
|
-
if (key.type === "detached") {
|
|
135
|
-
return false;
|
|
136
|
-
}
|
|
137
|
-
if (key.type === "local") {
|
|
138
|
-
return false;
|
|
139
|
-
}
|
|
140
|
-
return this.opAttributor?.tryGetAttributionInfo(key.seq) !== undefined;
|
|
141
|
-
}
|
|
142
|
-
async initialize(deltaManager, quorum, baseSnapshot, readBlob, shouldAddAttributorOnNewFile) {
|
|
143
|
-
const attributorTree = baseSnapshot?.trees[attributorTreeName];
|
|
144
|
-
// Existing documents that don't already have a snapshot containing runtime attribution info shouldn't
|
|
145
|
-
// inject any for now--this causes some back-compat integration problems that aren't fully worked out.
|
|
146
|
-
const shouldExcludeAttributor = (baseSnapshot !== undefined && attributorTree === undefined) ||
|
|
147
|
-
(baseSnapshot === undefined && !shouldAddAttributorOnNewFile);
|
|
148
|
-
if (shouldExcludeAttributor) {
|
|
149
|
-
// This gives a consistent error for calls to `get` on keys that don't exist.
|
|
150
|
-
this.opAttributor = new Attributor();
|
|
151
|
-
return;
|
|
152
|
-
}
|
|
153
|
-
this.isEnabled = true;
|
|
154
|
-
this.encoder = chain(new AttributorSerializer((entries) => new OpStreamAttributor(deltaManager, quorum, entries), deltaEncoder), makeLZ4Encoder());
|
|
155
|
-
if (attributorTree === undefined) {
|
|
156
|
-
this.opAttributor = new OpStreamAttributor(deltaManager, quorum);
|
|
157
|
-
}
|
|
158
|
-
else {
|
|
159
|
-
const id = attributorTree.blobs[opBlobName];
|
|
160
|
-
assert(id !== undefined, 0x50a /* Attributor tree should have op attributor summary blob. */);
|
|
161
|
-
const blobContents = await readBlob(id);
|
|
162
|
-
const attributorSnapshot = bufferToString(blobContents, "utf8");
|
|
163
|
-
this.opAttributor = this.encoder.decode(attributorSnapshot);
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
summarize() {
|
|
167
|
-
if (!this.isEnabled) {
|
|
168
|
-
// Loaded existing document without attributor data: avoid injecting any data.
|
|
169
|
-
return undefined;
|
|
170
|
-
}
|
|
171
|
-
assert(this.opAttributor !== undefined, 0x50b /* RuntimeAttributor should be initialized before summarization */);
|
|
172
|
-
const builder = new SummaryTreeBuilder();
|
|
173
|
-
builder.addBlob(opBlobName, this.encoder.encode(this.opAttributor));
|
|
174
|
-
return builder.getSummaryTree();
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
72
|
//# sourceMappingURL=mixinAttributor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mixinAttributor.js","sourceRoot":"","sources":["../src/mixinAttributor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAK9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,4CAA4C,CAAC;AAQ9E,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAc9E,OAAO,EACN,kBAAkB,EAClB,2BAA2B,GAC3B,MAAM,wCAAwC,CAAC;AAChD,OAAO,EACN,gBAAgB,EAChB,UAAU,EACV,iBAAiB,EACjB,yBAAyB,GACzB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AM,CAAC;YACP,MAAM,EAAE,GAAG,cAAc,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;YAC5C,MAAM,CACL,EAAE,KAAK,SAAS,EAChB,KAAK,CAAC,6DAA6D,CACnE,CAAC;YACF,MAAM,YAAY,GAAG,MAAM,QAAQ,CAAC,EAAE,CAAC,CAAC;YACxC,MAAM,kBAAkB,GAAG,cAAc,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;YAChE,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC;QAC7D,CAAC;IACF,CAAC;IAEM,SAAS;QACf,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;YACrB,8EAA8E;YAC9E,OAAO,SAAS,CAAC;QAClB,CAAC;QAED,MAAM,CACL,IAAI,CAAC,YAAY,KAAK,SAAS,EAC/B,KAAK,CAAC,kEAAkE,CACxE,CAAC;QACF,MAAM,OAAO,GAAG,IAAI,kBAAkB,EAAE,CAAC;QACzC,OAAO,CAAC,OAAO,CAAC,UAAU,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC;QACpE,OAAO,OAAO,CAAC,cAAc,EAAE,CAAC;IACjC,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 {\n\ttype IDeltaManager,\n\ttype IContainerContext,\n} from \"@fluidframework/container-definitions/internal\";\nimport { ContainerRuntime } from \"@fluidframework/container-runtime/internal\";\nimport type { IContainerRuntimeOptions } from \"@fluidframework/container-runtime/internal\";\nimport { type IContainerRuntime } from \"@fluidframework/container-runtime-definitions/internal\";\nimport {\n\ttype FluidObject,\n\ttype IRequest,\n\ttype IResponse,\n} from \"@fluidframework/core-interfaces\";\nimport { assert, unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport { type IQuorumClients } from \"@fluidframework/driver-definitions\";\nimport {\n\ttype IDocumentMessage,\n\ttype ISnapshotTree,\n\ttype ISequencedDocumentMessage,\n} from \"@fluidframework/driver-definitions/internal\";\nimport {\n\ttype ISummaryTreeWithStats,\n\ttype ITelemetryContext,\n\ttype AttributionInfo,\n\ttype AttributionKey,\n\ttype NamedFluidDataStoreRegistryEntries,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport {\n\tSummaryTreeBuilder,\n\taddSummarizeResultToSummary,\n} from \"@fluidframework/runtime-utils/internal\";\nimport {\n\tPerformanceEvent,\n\tUsageError,\n\tcreateChildLogger,\n\tloggerToMonitoringContext,\n} from \"@fluidframework/telemetry-utils/internal\";\n\nimport { Attributor, type IAttributor, OpStreamAttributor } from \"./attributor.js\";\nimport { AttributorSerializer, type Encoder, chain, deltaEncoder } from \"./encoders.js\";\nimport { makeLZ4Encoder } from \"./lz4Encoder.js\";\n\n// Summary tree keys\nconst attributorTreeName = \".attributor\";\nconst opBlobName = \"op\";\n\n/**\n * @internal\n */\nexport const enableOnNewFileKey = \"Fluid.Attribution.EnableOnNewFile\";\n\n/**\n * @internal\n */\nexport const IRuntimeAttributor: keyof IProvideRuntimeAttributor = \"IRuntimeAttributor\";\n\n/**\n * @internal\n */\nexport interface IProvideRuntimeAttributor {\n\treadonly IRuntimeAttributor: IRuntimeAttributor;\n}\n\n/**\n * Provides access to attribution information stored on the container runtime.\n *\n * @remarks Attributors are only populated after the container runtime into which they are being injected has initialized.\n *\n * @sealed\n * @internal\n */\nexport interface IRuntimeAttributor extends IProvideRuntimeAttributor {\n\t/**\n\t * @throws - If no AttributionInfo exists for this key.\n\t */\n\tget(key: AttributionKey): AttributionInfo;\n\n\t/**\n\t * @returns Whether any AttributionInfo exists for the provided key.\n\t */\n\thas(key: AttributionKey): boolean;\n\n\t/**\n\t * @returns Whether the runtime is currently tracking attribution information for the loaded container.\n\t * If enabled, the runtime attributor can be asked for the attribution info for different keys.\n\t * See {@link mixinAttributor} for more details on when this happens.\n\t */\n\treadonly isEnabled: boolean;\n}\n\n/**\n * Creates an `IRuntimeAttributor` for usage with {@link mixinAttributor}.\n *\n * @remarks The attributor will only be populated with data once it's passed via scope to a container runtime load flow.\n *\n * @internal\n */\nexport function createRuntimeAttributor(): IRuntimeAttributor {\n\treturn new RuntimeAttributor();\n}\n\n/**\n * Mixes in logic to load and store runtime-based attribution functionality.\n *\n * The `scope` passed to `load` should implement `IProvideRuntimeAttributor`.\n *\n * Existing documents without stored attributors will not start storing attribution information: if an\n * IRuntimeAttributor is passed via scope to load a document that never previously had attribution information,\n * that attributor's `has` method will always return `false`.\n * @param Base - base class, inherits from FluidAttributorRuntime\n * @internal\n */\nexport const mixinAttributor = (\n\tBase: typeof ContainerRuntime = ContainerRuntime,\n): typeof ContainerRuntime =>\n\tclass ContainerRuntimeWithAttributor extends Base {\n\t\tpublic static async loadRuntime(params: {\n\t\t\tcontext: IContainerContext;\n\t\t\tregistryEntries: NamedFluidDataStoreRegistryEntries;\n\t\t\texisting: boolean;\n\t\t\truntimeOptions?: IContainerRuntimeOptions;\n\t\t\tcontainerScope?: FluidObject;\n\t\t\tcontainerRuntimeCtor?: typeof ContainerRuntime;\n\t\t\t/**\n\t\t\t * @deprecated Will be removed once Loader LTS version is \"2.0.0-internal.7.0.0\". Migrate all usage of IFluidRouter to the \"entryPoint\" pattern. Refer to Removing-IFluidRouter.md\n\t\t\t */\n\t\t\trequestHandler?: (request: IRequest, runtime: IContainerRuntime) => Promise<IResponse>;\n\t\t\tprovideEntryPoint: (containerRuntime: IContainerRuntime) => Promise<FluidObject>;\n\t\t}): Promise<ContainerRuntime> {\n\t\t\tconst {\n\t\t\t\tcontext,\n\t\t\t\tregistryEntries,\n\t\t\t\texisting,\n\t\t\t\trequestHandler,\n\t\t\t\tprovideEntryPoint,\n\t\t\t\truntimeOptions,\n\t\t\t\tcontainerScope,\n\t\t\t\tcontainerRuntimeCtor = ContainerRuntimeWithAttributor as unknown as typeof ContainerRuntime,\n\t\t\t} = params;\n\n\t\t\tconst runtimeAttributor = (\n\t\t\t\tcontainerScope as FluidObject<IProvideRuntimeAttributor> | undefined\n\t\t\t)?.IRuntimeAttributor;\n\t\t\tif (!runtimeAttributor) {\n\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\"ContainerRuntimeWithAttributor must be passed a scope implementing IProvideRuntimeAttributor\",\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst pendingRuntimeState = context.pendingLocalState as {\n\t\t\t\tbaseSnapshot?: ISnapshotTree;\n\t\t\t};\n\t\t\tconst baseSnapshot: ISnapshotTree | undefined =\n\t\t\t\tpendingRuntimeState?.baseSnapshot ?? context.baseSnapshot;\n\n\t\t\tconst { quorum, deltaManager, taggedLogger } = context;\n\t\t\tassert(\n\t\t\t\tquorum !== undefined,\n\t\t\t\t0x968 /* quorum must exist when instantiating attribution-providing runtime */,\n\t\t\t);\n\n\t\t\tconst mc = loggerToMonitoringContext(taggedLogger);\n\n\t\t\tconst shouldTrackAttribution = mc.config.getBoolean(enableOnNewFileKey) ?? false;\n\t\t\tif (shouldTrackAttribution) {\n\t\t\t\tconst { options } = context;\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n\t\t\t\t(options.attribution ??= {}).track = true;\n\t\t\t}\n\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n\t\t\tconst runtime = (await Base.loadRuntime({\n\t\t\t\tcontext,\n\t\t\t\tregistryEntries,\n\t\t\t\trequestHandler,\n\t\t\t\tprovideEntryPoint,\n\t\t\t\t// ! This prop is needed for back-compat. Can be removed in 2.0.0-internal.8.0.0\n\t\t\t\tinitializeEntryPoint: provideEntryPoint,\n\t\t\t\truntimeOptions,\n\t\t\t\tcontainerScope,\n\t\t\t\texisting,\n\t\t\t\tcontainerRuntimeCtor,\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t\t} as any)) as ContainerRuntimeWithAttributor;\n\t\t\truntime.runtimeAttributor = runtimeAttributor as RuntimeAttributor;\n\n\t\t\tconst logger = createChildLogger({\n\t\t\t\tlogger: runtime.baseLogger,\n\t\t\t\tnamespace: \"Attributor\",\n\t\t\t});\n\n\t\t\t// Note: this fetches attribution blobs relatively eagerly in the load flow; we may want to optimize\n\t\t\t// this to avoid blocking on such information until application actually requests some op-based attribution\n\t\t\t// info or we need to summarize. All that really needs to happen immediately is to start recording\n\t\t\t// op seq# -> attributionInfo for new ops.\n\t\t\tawait PerformanceEvent.timedExecAsync(\n\t\t\t\tlogger,\n\t\t\t\t{\n\t\t\t\t\teventName: \"initialize\",\n\t\t\t\t},\n\t\t\t\tasync (event) => {\n\t\t\t\t\tawait runtime.runtimeAttributor?.initialize(\n\t\t\t\t\t\tdeltaManager,\n\t\t\t\t\t\tquorum,\n\t\t\t\t\t\tbaseSnapshot,\n\t\t\t\t\t\tasync (id) => runtime.storage.readBlob(id),\n\t\t\t\t\t\tshouldTrackAttribution,\n\t\t\t\t\t);\n\t\t\t\t\tevent.end({\n\t\t\t\t\t\tattributionEnabledInConfig: shouldTrackAttribution,\n\t\t\t\t\t\tattributionEnabledInDoc: runtime.runtimeAttributor\n\t\t\t\t\t\t\t? runtime.runtimeAttributor.isEnabled\n\t\t\t\t\t\t\t: false,\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t);\n\n\t\t\treturn runtime;\n\t\t}\n\n\t\tprivate runtimeAttributor: RuntimeAttributor | undefined;\n\n\t\tprotected addContainerStateToSummary(\n\t\t\tsummaryTree: ISummaryTreeWithStats,\n\t\t\tfullTree: boolean,\n\t\t\ttrackState: boolean,\n\t\t\ttelemetryContext?: ITelemetryContext,\n\t\t): void {\n\t\t\tsuper.addContainerStateToSummary(summaryTree, fullTree, trackState, telemetryContext);\n\t\t\tconst attributorSummary = this.runtimeAttributor?.summarize();\n\t\t\tif (attributorSummary) {\n\t\t\t\taddSummarizeResultToSummary(summaryTree, attributorTreeName, attributorSummary);\n\t\t\t}\n\t\t}\n\t} as unknown as typeof ContainerRuntime;\n\nclass RuntimeAttributor implements IRuntimeAttributor {\n\tpublic get IRuntimeAttributor(): IRuntimeAttributor {\n\t\treturn this;\n\t}\n\n\tpublic get(key: AttributionKey): AttributionInfo {\n\t\tassert(\n\t\t\tthis.opAttributor !== undefined,\n\t\t\t0x509 /* RuntimeAttributor must be initialized before getAttributionInfo can be called */,\n\t\t);\n\n\t\tif (key.type === \"detached\") {\n\t\t\tthrow new Error(\"Attribution of detached keys is not yet supported.\");\n\t\t}\n\n\t\tif (key.type === \"local\") {\n\t\t\t// Note: we can *almost* orchestrate this correctly with internal-only changes by looking up the current\n\t\t\t// client id in the audience. However, for read->write client transition, the container might have not yet\n\t\t\t// received a client id. This is left as a TODO as it might be more easily solved once the detached case\n\t\t\t// is settled (e.g. if it's reasonable for the host to know the current user information at container\n\t\t\t// creation time, we could just use that here as well).\n\t\t\tthrow new Error(\"Attribution of local keys is not yet supported.\");\n\t\t}\n\n\t\treturn this.opAttributor.getAttributionInfo(key.seq);\n\t}\n\n\tpublic has(key: AttributionKey): boolean {\n\t\tif (key.type === \"detached\") {\n\t\t\treturn false;\n\t\t}\n\n\t\tif (key.type === \"local\") {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn this.opAttributor?.tryGetAttributionInfo(key.seq) !== undefined;\n\t}\n\n\tprivate encoder: Encoder<IAttributor, string> = {\n\t\tencode: unreachableCase,\n\t\tdecode: unreachableCase,\n\t};\n\n\tprivate opAttributor: IAttributor | undefined;\n\tpublic isEnabled = false;\n\n\tpublic async initialize(\n\t\tdeltaManager: IDeltaManager<ISequencedDocumentMessage, IDocumentMessage>,\n\t\tquorum: IQuorumClients,\n\t\tbaseSnapshot: ISnapshotTree | undefined,\n\t\treadBlob: (id: string) => Promise<ArrayBufferLike>,\n\t\tshouldAddAttributorOnNewFile: boolean,\n\t): Promise<void> {\n\t\tconst attributorTree = baseSnapshot?.trees[attributorTreeName];\n\t\t// Existing documents that don't already have a snapshot containing runtime attribution info shouldn't\n\t\t// inject any for now--this causes some back-compat integration problems that aren't fully worked out.\n\t\tconst shouldExcludeAttributor =\n\t\t\t(baseSnapshot !== undefined && attributorTree === undefined) ||\n\t\t\t(baseSnapshot === undefined && !shouldAddAttributorOnNewFile);\n\t\tif (shouldExcludeAttributor) {\n\t\t\t// This gives a consistent error for calls to `get` on keys that don't exist.\n\t\t\tthis.opAttributor = new Attributor();\n\t\t\treturn;\n\t\t}\n\n\t\tthis.isEnabled = true;\n\t\tthis.encoder = chain(\n\t\t\tnew AttributorSerializer(\n\t\t\t\t(entries) => new OpStreamAttributor(deltaManager, quorum, entries),\n\t\t\t\tdeltaEncoder,\n\t\t\t),\n\t\t\tmakeLZ4Encoder(),\n\t\t);\n\n\t\tif (attributorTree === undefined) {\n\t\t\tthis.opAttributor = new OpStreamAttributor(deltaManager, quorum);\n\t\t} else {\n\t\t\tconst id = attributorTree.blobs[opBlobName];\n\t\t\tassert(\n\t\t\t\tid !== undefined,\n\t\t\t\t0x50a /* Attributor tree should have op attributor summary blob. */,\n\t\t\t);\n\t\t\tconst blobContents = await readBlob(id);\n\t\t\tconst attributorSnapshot = bufferToString(blobContents, \"utf8\");\n\t\t\tthis.opAttributor = this.encoder.decode(attributorSnapshot);\n\t\t}\n\t}\n\n\tpublic summarize(): ISummaryTreeWithStats | undefined {\n\t\tif (!this.isEnabled) {\n\t\t\t// Loaded existing document without attributor data: avoid injecting any data.\n\t\t\treturn undefined;\n\t\t}\n\n\t\tassert(\n\t\t\tthis.opAttributor !== undefined,\n\t\t\t0x50b /* RuntimeAttributor should be initialized before summarization */,\n\t\t);\n\t\tconst builder = new SummaryTreeBuilder();\n\t\tbuilder.addBlob(opBlobName, this.encoder.encode(this.opAttributor));\n\t\treturn builder.getSummaryTree();\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"mixinAttributor.js","sourceRoot":"","sources":["../src/mixinAttributor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,gBAAgB,EA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C5B,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;YAC5B,sEAAsE;YACtE,CAAC,OAAO,CAAC,WAAW,KAAnB,OAAO,CAAC,WAAW,GAAK,EAAE,EAAC,CAAC,KAAK,GAAG,IAAI,CAAC;QAC3C,CAAC;QAED,iEAAiE;QACjE,MAAM,OAAO,GAAG,CAAC,MAAM,IAAI,CAAC,WAAW,CAAC;YACvC,OAAO;YACP,eAAe,EAAE,mBAAmB;YACpC,cAAc;YACd,iBAAiB;YACjB,cAAc;YACd,cAAc;YACd,QAAQ;YACR,oBAAoB;YACpB,8DAA8D;SACvD,CAAC,CAAmC,CAAC;QAE7C,IAAI,iBAAiD,CAAC;QACtD,IAAI,sBAAsB,EAAE,CAAC;YAC5B,IAAI,QAAQ,EAAE,CAAC;gBACd,iBAAiB,GAAG,MAAM,oBAAoB,CAAC,OAAO,CAAC,CAAC;YACzD,CAAC;iBAAM,CAAC;gBACP,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC,eAAe,CAAC,wBAAwB,CAAC,IAAI,CAAC,CAAC;gBAC/E,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,WAAW,CAAC,wBAAwB,CAAC,CAAC;gBACrE,MAAM,CACL,MAAM,KAAK,SAAS,EACpB,KAAK,CAAC,mDAAmD,CACzD,CAAC;gBACF,iBAAiB,GAAG,CAAC,MAAM,SAAS,CAAC,UAAU,CAAC,GAAG,EAAE,CAAuB,CAAC;gBAC7E,MAAM,CAAC,iBAAiB,KAAK,SAAS,EAAE,KAAK,CAAC,kCAAkC,CAAC,CAAC;YACnF,CAAC;QACF,CAAC;QAED,OAAO,OAAO,CAAC;IAChB,CAAC;CACqC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { type IContainerContext } from \"@fluidframework/container-definitions/internal\";\nimport { ContainerRuntime } from \"@fluidframework/container-runtime/internal\";\nimport type { IContainerRuntimeOptions } from \"@fluidframework/container-runtime/internal\";\nimport { type IContainerRuntime } from \"@fluidframework/container-runtime-definitions/internal\";\nimport {\n\ttype FluidObject,\n\ttype IRequest,\n\ttype IResponse,\n} from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { type NamedFluidDataStoreRegistryEntries } from \"@fluidframework/runtime-definitions/internal\";\nimport { loggerToMonitoringContext } from \"@fluidframework/telemetry-utils/internal\";\n\nimport {\n\tattributorDataStoreAlias,\n\tenableOnNewFileKey,\n\ttype IProvideRuntimeAttributor,\n\ttype IRuntimeAttributor,\n} from \"./attributorContracts.js\";\nimport { RuntimeAttributorFactory } from \"./runtimeAttributorDataStoreFactory.js\";\n\n/**\n * Utility function to get the runtime attributor from the container runtime.\n * @param runtime - container runtime from which attributor is to be fetched.\n * @returns IRuntimeAttributor if it exists, otherwise undefined.\n * @internal\n */\nexport async function getRuntimeAttributor(\n\truntime: IContainerRuntime,\n): Promise<IRuntimeAttributor | undefined> {\n\tconst entryPoint = await runtime.getAliasedDataStoreEntryPoint(attributorDataStoreAlias);\n\tconst runtimeAttributor = (await entryPoint?.get()) as\n\t\t| FluidObject<IProvideRuntimeAttributor>\n\t\t| undefined;\n\treturn runtimeAttributor?.IRuntimeAttributor;\n}\n\n/**\n * Mixes in logic to load and store runtime-based attribution functionality.\n *\n * Existing documents without stored attributor will not start storing attribution information. We only create the attributor\n * if its tracking is enabled and we are creating a new document.\n * @param Base - base class, inherits from FluidAttributorRuntime\n * @internal\n */\nexport const mixinAttributor = (\n\tBase: typeof ContainerRuntime = ContainerRuntime,\n): typeof ContainerRuntime =>\n\tclass ContainerRuntimeWithAttributor extends Base {\n\t\tpublic static async loadRuntime(params: {\n\t\t\tcontext: IContainerContext;\n\t\t\tregistryEntries: NamedFluidDataStoreRegistryEntries;\n\t\t\texisting: boolean;\n\t\t\truntimeOptions?: IContainerRuntimeOptions;\n\t\t\tcontainerScope?: FluidObject;\n\t\t\tcontainerRuntimeCtor?: typeof ContainerRuntime;\n\t\t\t/**\n\t\t\t * @deprecated Will be removed once Loader LTS version is \"2.0.0-internal.7.0.0\". Migrate all usage of IFluidRouter to the \"entryPoint\" pattern. Refer to Removing-IFluidRouter.md\n\t\t\t */\n\t\t\trequestHandler?: (request: IRequest, runtime: IContainerRuntime) => Promise<IResponse>;\n\t\t\tprovideEntryPoint: (containerRuntime: IContainerRuntime) => Promise<FluidObject>;\n\t\t}): Promise<ContainerRuntime> {\n\t\t\tconst {\n\t\t\t\tcontext,\n\t\t\t\tregistryEntries,\n\t\t\t\texisting,\n\t\t\t\trequestHandler,\n\t\t\t\tprovideEntryPoint,\n\t\t\t\truntimeOptions,\n\t\t\t\tcontainerScope,\n\t\t\t\tcontainerRuntimeCtor = ContainerRuntimeWithAttributor as unknown as typeof ContainerRuntime,\n\t\t\t} = params;\n\n\t\t\tconst mc = loggerToMonitoringContext(context.taggedLogger);\n\t\t\tconst factory = new RuntimeAttributorFactory();\n\t\t\tconst registryEntriesCopy: NamedFluidDataStoreRegistryEntries = [\n\t\t\t\t...registryEntries,\n\t\t\t\t[RuntimeAttributorFactory.type, Promise.resolve(factory)],\n\t\t\t];\n\t\t\tconst shouldTrackAttribution = mc.config.getBoolean(enableOnNewFileKey) ?? false;\n\t\t\tif (shouldTrackAttribution) {\n\t\t\t\tconst { options } = context;\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n\t\t\t\t(options.attribution ??= {}).track = true;\n\t\t\t}\n\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n\t\t\tconst runtime = (await Base.loadRuntime({\n\t\t\t\tcontext,\n\t\t\t\tregistryEntries: registryEntriesCopy,\n\t\t\t\trequestHandler,\n\t\t\t\tprovideEntryPoint,\n\t\t\t\truntimeOptions,\n\t\t\t\tcontainerScope,\n\t\t\t\texisting,\n\t\t\t\tcontainerRuntimeCtor,\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t\t} as any)) as ContainerRuntimeWithAttributor;\n\n\t\t\tlet runtimeAttributor: IRuntimeAttributor | undefined;\n\t\t\tif (shouldTrackAttribution) {\n\t\t\t\tif (existing) {\n\t\t\t\t\truntimeAttributor = await getRuntimeAttributor(runtime);\n\t\t\t\t} else {\n\t\t\t\t\tconst datastore = await runtime.createDataStore(RuntimeAttributorFactory.type);\n\t\t\t\t\tconst result = await datastore.trySetAlias(attributorDataStoreAlias);\n\t\t\t\t\tassert(\n\t\t\t\t\t\tresult === \"Success\",\n\t\t\t\t\t\t0xa1b /* Failed to set alias for attributor data store */,\n\t\t\t\t\t);\n\t\t\t\t\truntimeAttributor = (await datastore.entryPoint.get()) as IRuntimeAttributor;\n\t\t\t\t\tassert(runtimeAttributor !== undefined, 0xa1c /* Attributor should be defined */);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn runtime;\n\t\t}\n\t} as unknown as typeof ContainerRuntime;\n"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { IDeltaManager } from "@fluidframework/container-definitions/internal";
|
|
6
|
+
import { IDocumentMessage, type ISnapshotTree, ISequencedDocumentMessage, IQuorumClients } from "@fluidframework/driver-definitions/internal";
|
|
7
|
+
import { type AttributionInfo, type AttributionKey, type ISummaryTreeWithStats } from "@fluidframework/runtime-definitions/internal";
|
|
8
|
+
import { type IRuntimeAttributor } from "./attributorContracts.js";
|
|
9
|
+
export declare class RuntimeAttributor implements IRuntimeAttributor {
|
|
10
|
+
get IRuntimeAttributor(): IRuntimeAttributor;
|
|
11
|
+
get(key: AttributionKey): AttributionInfo;
|
|
12
|
+
has(key: AttributionKey): boolean;
|
|
13
|
+
private encoder;
|
|
14
|
+
private opAttributor;
|
|
15
|
+
isEnabled: boolean;
|
|
16
|
+
initialize(deltaManager: IDeltaManager<ISequencedDocumentMessage, IDocumentMessage>, quorum: IQuorumClients, baseSnapshotForAttributorTree: ISnapshotTree | undefined, readBlob: (id: string) => Promise<ArrayBufferLike>): Promise<void>;
|
|
17
|
+
summarizeOpAttributor(): ISummaryTreeWithStats;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=runtimeAttributor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtimeAttributor.d.ts","sourceRoot":"","sources":["../src/runtimeAttributor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,aAAa,EAAE,MAAM,gDAAgD,CAAC;AAE/E,OAAO,EACN,gBAAgB,EAChB,KAAK,aAAa,EAClB,yBAAyB,EACzB,cAAc,EACd,MAAM,6CAA6C,CAAC;AACrD,OAAO,EACN,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,qBAAqB,EAC1B,MAAM,8CAA8C,CAAC;AAItD,OAAO,EAAc,KAAK,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAI/E,qBAAa,iBAAkB,YAAW,kBAAkB;IAC3D,IAAW,kBAAkB,IAAI,kBAAkB,CAElD;IAEM,GAAG,CAAC,GAAG,EAAE,cAAc,GAAG,eAAe;IAsBzC,GAAG,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO;IAYxC,OAAO,CAAC,OAAO,CAGb;IAEF,OAAO,CAAC,YAAY,CAA0B;IACvC,SAAS,UAAQ;IAEX,UAAU,CACtB,YAAY,EAAE,aAAa,CAAC,yBAAyB,EAAE,gBAAgB,CAAC,EACxE,MAAM,EAAE,cAAc,EACtB,6BAA6B,EAAE,aAAa,GAAG,SAAS,EACxD,QAAQ,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,eAAe,CAAC,GAChD,OAAO,CAAC,IAAI,CAAC;IAuBT,qBAAqB,IAAI,qBAAqB;CASrD"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { bufferToString } from "@fluid-internal/client-utils";
|
|
6
|
+
import { assert, unreachableCase } from "@fluidframework/core-utils/internal";
|
|
7
|
+
import { SummaryTreeBuilder } from "@fluidframework/runtime-utils/internal";
|
|
8
|
+
import { OpStreamAttributor } from "./attributor.js";
|
|
9
|
+
import { opBlobName } from "./attributorContracts.js";
|
|
10
|
+
import { AttributorSerializer, chain, deltaEncoder } from "./encoders.js";
|
|
11
|
+
import { makeLZ4Encoder } from "./lz4Encoder.js";
|
|
12
|
+
export class RuntimeAttributor {
|
|
13
|
+
constructor() {
|
|
14
|
+
this.encoder = {
|
|
15
|
+
encode: unreachableCase,
|
|
16
|
+
decode: unreachableCase,
|
|
17
|
+
};
|
|
18
|
+
this.isEnabled = true;
|
|
19
|
+
}
|
|
20
|
+
get IRuntimeAttributor() {
|
|
21
|
+
return this;
|
|
22
|
+
}
|
|
23
|
+
get(key) {
|
|
24
|
+
assert(this.opAttributor !== undefined, 0x509 /* RuntimeAttributor must be initialized before getAttributionInfo can be called */);
|
|
25
|
+
if (key.type === "detached") {
|
|
26
|
+
throw new Error("Attribution of detached keys is not yet supported.");
|
|
27
|
+
}
|
|
28
|
+
if (key.type === "local") {
|
|
29
|
+
// Note: we can *almost* orchestrate this correctly with internal-only changes by looking up the current
|
|
30
|
+
// client id in the audience. However, for read->write client transition, the container might have not yet
|
|
31
|
+
// received a client id. This is left as a TODO as it might be more easily solved once the detached case
|
|
32
|
+
// is settled (e.g. if it's reasonable for the host to know the current user information at container
|
|
33
|
+
// creation time, we could just use that here as well).
|
|
34
|
+
throw new Error("Attribution of local keys is not yet supported.");
|
|
35
|
+
}
|
|
36
|
+
return this.opAttributor.getAttributionInfo(key.seq);
|
|
37
|
+
}
|
|
38
|
+
has(key) {
|
|
39
|
+
if (key.type === "detached") {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
if (key.type === "local") {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
return this.opAttributor?.tryGetAttributionInfo(key.seq) !== undefined;
|
|
46
|
+
}
|
|
47
|
+
async initialize(deltaManager, quorum, baseSnapshotForAttributorTree, readBlob) {
|
|
48
|
+
this.encoder = chain(new AttributorSerializer((entries) => new OpStreamAttributor(deltaManager, quorum, entries), deltaEncoder), makeLZ4Encoder());
|
|
49
|
+
if (baseSnapshotForAttributorTree === undefined) {
|
|
50
|
+
this.opAttributor = new OpStreamAttributor(deltaManager, quorum);
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
const id = baseSnapshotForAttributorTree.blobs[opBlobName];
|
|
54
|
+
assert(id !== undefined, 0x50a /* Attributor tree should have op attributor summary blob. */);
|
|
55
|
+
const blobContents = await readBlob(id);
|
|
56
|
+
const attributorSnapshot = bufferToString(blobContents, "utf8");
|
|
57
|
+
this.opAttributor = this.encoder.decode(attributorSnapshot);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
summarizeOpAttributor() {
|
|
61
|
+
assert(this.opAttributor !== undefined, 0xa1d /* RuntimeAttributor should be initialized before summarization */);
|
|
62
|
+
const builder = new SummaryTreeBuilder();
|
|
63
|
+
builder.addBlob(opBlobName, this.encoder.encode(this.opAttributor));
|
|
64
|
+
return builder.getSummaryTree();
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=runtimeAttributor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtimeAttributor.js","sourceRoot":"","sources":["../src/runtimeAttributor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAE9D,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAY9E,OAAO,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AAE5E,OAAO,EAAE,kBAAkB,EAAoB,MAA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AAC;IAUM,KAAK,CAAC,UAAU,CACtB,YAAwE,EACxE,MAAsB,EACtB,6BAAwD,EACxD,QAAkD;QAElD,IAAI,CAAC,OAAO,GAAG,KAAK,CACnB,IAAI,oBAAoB,CACvB,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,kBAAkB,CAAC,YAAY,EAAE,MAAM,EAAE,OAAO,CAAC,EAClE,YAAY,CACZ,EACD,cAAc,EAAE,CAChB,CAAC;QAEF,IAAI,6BAA6B,KAAK,SAAS,EAAE,CAAC;YACjD,IAAI,CAAC,YAAY,GAAG,IAAI,kBAAkB,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;QAClE,CAAC;aAAM,CAAC;YACP,MAAM,EAAE,GAAG,6BAA6B,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;YAC3D,MAAM,CACL,EAAE,KAAK,SAAS,EAChB,KAAK,CAAC,6DAA6D,CACnE,CAAC;YACF,MAAM,YAAY,GAAG,MAAM,QAAQ,CAAC,EAAE,CAAC,CAAC;YACxC,MAAM,kBAAkB,GAAG,cAAc,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;YAChE,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC;QAC7D,CAAC;IACF,CAAC;IAEM,qBAAqB;QAC3B,MAAM,CACL,IAAI,CAAC,YAAY,KAAK,SAAS,EAC/B,KAAK,CAAC,kEAAkE,CACxE,CAAC;QACF,MAAM,OAAO,GAAG,IAAI,kBAAkB,EAAE,CAAC;QACzC,OAAO,CAAC,OAAO,CAAC,UAAU,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC;QACpE,OAAO,OAAO,CAAC,cAAc,EAAE,CAAC;IACjC,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 { IDeltaManager } from \"@fluidframework/container-definitions/internal\";\nimport { assert, unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport {\n\tIDocumentMessage,\n\ttype ISnapshotTree,\n\tISequencedDocumentMessage,\n\tIQuorumClients,\n} from \"@fluidframework/driver-definitions/internal\";\nimport {\n\ttype AttributionInfo,\n\ttype AttributionKey,\n\ttype ISummaryTreeWithStats,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport { SummaryTreeBuilder } from \"@fluidframework/runtime-utils/internal\";\n\nimport { OpStreamAttributor, type IAttributor } from \"./attributor.js\";\nimport { opBlobName, type IRuntimeAttributor } from \"./attributorContracts.js\";\nimport { AttributorSerializer, chain, deltaEncoder, type Encoder } from \"./encoders.js\";\nimport { makeLZ4Encoder } from \"./lz4Encoder.js\";\n\nexport class RuntimeAttributor implements IRuntimeAttributor {\n\tpublic get IRuntimeAttributor(): IRuntimeAttributor {\n\t\treturn this;\n\t}\n\n\tpublic get(key: AttributionKey): AttributionInfo {\n\t\tassert(\n\t\t\tthis.opAttributor !== undefined,\n\t\t\t0x509 /* RuntimeAttributor must be initialized before getAttributionInfo can be called */,\n\t\t);\n\n\t\tif (key.type === \"detached\") {\n\t\t\tthrow new Error(\"Attribution of detached keys is not yet supported.\");\n\t\t}\n\n\t\tif (key.type === \"local\") {\n\t\t\t// Note: we can *almost* orchestrate this correctly with internal-only changes by looking up the current\n\t\t\t// client id in the audience. However, for read->write client transition, the container might have not yet\n\t\t\t// received a client id. This is left as a TODO as it might be more easily solved once the detached case\n\t\t\t// is settled (e.g. if it's reasonable for the host to know the current user information at container\n\t\t\t// creation time, we could just use that here as well).\n\t\t\tthrow new Error(\"Attribution of local keys is not yet supported.\");\n\t\t}\n\n\t\treturn this.opAttributor.getAttributionInfo(key.seq);\n\t}\n\n\tpublic has(key: AttributionKey): boolean {\n\t\tif (key.type === \"detached\") {\n\t\t\treturn false;\n\t\t}\n\n\t\tif (key.type === \"local\") {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn this.opAttributor?.tryGetAttributionInfo(key.seq) !== undefined;\n\t}\n\n\tprivate encoder: Encoder<IAttributor, string> = {\n\t\tencode: unreachableCase,\n\t\tdecode: unreachableCase,\n\t};\n\n\tprivate opAttributor: IAttributor | undefined;\n\tpublic isEnabled = true;\n\n\tpublic async initialize(\n\t\tdeltaManager: IDeltaManager<ISequencedDocumentMessage, IDocumentMessage>,\n\t\tquorum: IQuorumClients,\n\t\tbaseSnapshotForAttributorTree: ISnapshotTree | undefined,\n\t\treadBlob: (id: string) => Promise<ArrayBufferLike>,\n\t): Promise<void> {\n\t\tthis.encoder = chain(\n\t\t\tnew AttributorSerializer(\n\t\t\t\t(entries) => new OpStreamAttributor(deltaManager, quorum, entries),\n\t\t\t\tdeltaEncoder,\n\t\t\t),\n\t\t\tmakeLZ4Encoder(),\n\t\t);\n\n\t\tif (baseSnapshotForAttributorTree === undefined) {\n\t\t\tthis.opAttributor = new OpStreamAttributor(deltaManager, quorum);\n\t\t} else {\n\t\t\tconst id = baseSnapshotForAttributorTree.blobs[opBlobName];\n\t\t\tassert(\n\t\t\t\tid !== undefined,\n\t\t\t\t0x50a /* Attributor tree should have op attributor summary blob. */,\n\t\t\t);\n\t\t\tconst blobContents = await readBlob(id);\n\t\t\tconst attributorSnapshot = bufferToString(blobContents, \"utf8\");\n\t\t\tthis.opAttributor = this.encoder.decode(attributorSnapshot);\n\t\t}\n\t}\n\n\tpublic summarizeOpAttributor(): ISummaryTreeWithStats {\n\t\tassert(\n\t\t\tthis.opAttributor !== undefined,\n\t\t\t0xa1d /* RuntimeAttributor should be initialized before summarization */,\n\t\t);\n\t\tconst builder = new SummaryTreeBuilder();\n\t\tbuilder.addBlob(opBlobName, this.encoder.encode(this.opAttributor));\n\t\treturn builder.getSummaryTree();\n\t}\n}\n"]}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { TypedEventEmitter } from "@fluid-internal/client-utils";
|
|
6
|
+
import { AttachState, IDeltaManager } from "@fluidframework/container-definitions/internal";
|
|
7
|
+
import { FluidObject, IRequest, IResponse } from "@fluidframework/core-interfaces";
|
|
8
|
+
import type { IFluidHandleInternal } from "@fluidframework/core-interfaces/internal";
|
|
9
|
+
import { IFluidDataStoreRuntimeEvents } from "@fluidframework/datastore-definitions/internal";
|
|
10
|
+
import { IDocumentMessage, type ISnapshotTree, ISequencedDocumentMessage, IQuorumClients } from "@fluidframework/driver-definitions/internal";
|
|
11
|
+
import { IGarbageCollectionData, IFluidDataStoreChannel, IFluidDataStoreContext, IInboundSignalMessage, VisibilityState, type ISummaryTreeWithStats, type ITelemetryContext } from "@fluidframework/runtime-definitions/internal";
|
|
12
|
+
import { ITelemetryLoggerExt } from "@fluidframework/telemetry-utils/internal";
|
|
13
|
+
/**
|
|
14
|
+
* Data store channel for the runtime attributor. This channel is responsible for storing and managing the
|
|
15
|
+
*/
|
|
16
|
+
export declare class RuntimeAttributorDataStoreChannel extends TypedEventEmitter<IFluidDataStoreRuntimeEvents> implements IFluidDataStoreChannel {
|
|
17
|
+
readonly dataStoreContext: IFluidDataStoreContext;
|
|
18
|
+
constructor(dataStoreContext: IFluidDataStoreContext, existing: boolean);
|
|
19
|
+
get IFluidDataStoreChannel(): IFluidDataStoreChannel;
|
|
20
|
+
private _disposed;
|
|
21
|
+
get disposed(): boolean;
|
|
22
|
+
dispose(): void;
|
|
23
|
+
private readonly runtimeAttributor;
|
|
24
|
+
isEnabled: boolean;
|
|
25
|
+
attachState: AttachState;
|
|
26
|
+
visibilityState: VisibilityState;
|
|
27
|
+
private readonly deferredAttached;
|
|
28
|
+
private readonly mc;
|
|
29
|
+
get logger(): ITelemetryLoggerExt;
|
|
30
|
+
initialize(deltaManager: IDeltaManager<ISequencedDocumentMessage, IDocumentMessage>, quorum: IQuorumClients, baseSnapshotForAttributorTree: ISnapshotTree | undefined, readBlob: (id: string) => Promise<ArrayBufferLike>): Promise<void>;
|
|
31
|
+
/**
|
|
32
|
+
* {@inheritdoc IFluidDataStoreChannel.makeVisibleAndAttachGraph}
|
|
33
|
+
*/
|
|
34
|
+
makeVisibleAndAttachGraph(): void;
|
|
35
|
+
/**
|
|
36
|
+
* {@inheritdoc IFluidDataStoreChannel.getAttachSummary}
|
|
37
|
+
*/
|
|
38
|
+
getAttachSummary(telemetryContext?: ITelemetryContext): ISummaryTreeWithStats;
|
|
39
|
+
/**
|
|
40
|
+
* {@inheritdoc IFluidDataStoreChannel.getAttachGCData}
|
|
41
|
+
*/
|
|
42
|
+
getAttachGCData(telemetryContext?: ITelemetryContext): IGarbageCollectionData;
|
|
43
|
+
/**
|
|
44
|
+
* {@inheritdoc IFluidDataStoreChannel.process}
|
|
45
|
+
*/
|
|
46
|
+
process(message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown): void;
|
|
47
|
+
/**
|
|
48
|
+
* {@inheritdoc IFluidDataStoreChannel.processSignal}
|
|
49
|
+
*/
|
|
50
|
+
processSignal(message: IInboundSignalMessage, local: boolean): void;
|
|
51
|
+
/**
|
|
52
|
+
* {@inheritdoc IFluidDataStoreChannel.summarize}
|
|
53
|
+
*/
|
|
54
|
+
summarize(fullTree?: boolean, trackState?: boolean, telemetryContext?: ITelemetryContext): Promise<ISummaryTreeWithStats>;
|
|
55
|
+
/**
|
|
56
|
+
* {@inheritdoc IFluidDataStoreChannel.getGCData}
|
|
57
|
+
*/
|
|
58
|
+
getGCData(fullGC?: boolean): Promise<IGarbageCollectionData>;
|
|
59
|
+
/**
|
|
60
|
+
* {@inheritdoc IFluidDataStoreChannel.updateUsedRoutes}
|
|
61
|
+
*/
|
|
62
|
+
updateUsedRoutes(usedRoutes: string[]): void;
|
|
63
|
+
/**
|
|
64
|
+
* {@inheritdoc IFluidDataStoreChannel.setConnectionState}
|
|
65
|
+
*/
|
|
66
|
+
setConnectionState(connected: boolean, clientId?: string): void;
|
|
67
|
+
/**
|
|
68
|
+
* {@inheritdoc IFluidDataStoreChannel.reSubmit}
|
|
69
|
+
*/
|
|
70
|
+
reSubmit(type: string, content: unknown, localOpMetadata: unknown): void;
|
|
71
|
+
/**
|
|
72
|
+
* {@inheritdoc IFluidDataStoreChannel.applyStashedOp}
|
|
73
|
+
*/
|
|
74
|
+
applyStashedOp(content: unknown): Promise<unknown>;
|
|
75
|
+
/**
|
|
76
|
+
* {@inheritdoc IFluidDataStoreChannel.rollback}
|
|
77
|
+
*/
|
|
78
|
+
rollback?(type: string, content: unknown, localOpMetadata: unknown): void;
|
|
79
|
+
/**
|
|
80
|
+
* {@inheritdoc IFluidDataStoreChannel.entryPoint}
|
|
81
|
+
*/
|
|
82
|
+
readonly entryPoint: IFluidHandleInternal<FluidObject>;
|
|
83
|
+
/**
|
|
84
|
+
* {@inheritdoc IFluidDataStoreChannel.request}
|
|
85
|
+
*/
|
|
86
|
+
request(request: IRequest): Promise<IResponse>;
|
|
87
|
+
/**
|
|
88
|
+
* {@inheritdoc IFluidDataStoreChannel.setAttachState}
|
|
89
|
+
*/
|
|
90
|
+
setAttachState(attachState: AttachState.Attaching | AttachState.Attached): void;
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=runtimeAttributorDataStoreChannel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtimeAttributorDataStoreChannel.d.ts","sourceRoot":"","sources":["../src/runtimeAttributorDataStoreChannel.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,gDAAgD,CAAC;AAC5F,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACnF,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0CAA0C,CAAC;AAGrF,OAAO,EA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