@fluidframework/container-runtime 0.53.0-46105 → 0.54.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/containerRuntime.d.ts +25 -16
- package/dist/containerRuntime.d.ts.map +1 -1
- package/dist/containerRuntime.js +125 -77
- package/dist/containerRuntime.js.map +1 -1
- package/dist/dataStoreContext.d.ts +29 -3
- package/dist/dataStoreContext.d.ts.map +1 -1
- package/dist/dataStoreContext.js +29 -4
- package/dist/dataStoreContext.js.map +1 -1
- package/dist/dataStores.d.ts +7 -3
- package/dist/dataStores.d.ts.map +1 -1
- package/dist/dataStores.js +54 -5
- package/dist/dataStores.js.map +1 -1
- package/dist/garbageCollection.d.ts +22 -2
- package/dist/garbageCollection.d.ts.map +1 -1
- package/dist/garbageCollection.js +112 -34
- package/dist/garbageCollection.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.d.ts.map +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/runningSummarizer.d.ts +3 -2
- package/dist/runningSummarizer.d.ts.map +1 -1
- package/dist/runningSummarizer.js +6 -6
- package/dist/runningSummarizer.js.map +1 -1
- package/dist/summarizer.d.ts +22 -0
- package/dist/summarizer.d.ts.map +1 -1
- package/dist/summarizer.js +135 -33
- package/dist/summarizer.js.map +1 -1
- package/dist/summarizerTypes.d.ts +1 -8
- package/dist/summarizerTypes.d.ts.map +1 -1
- package/dist/summarizerTypes.js.map +1 -1
- package/dist/summaryFormat.d.ts +1 -0
- package/dist/summaryFormat.d.ts.map +1 -1
- package/dist/summaryFormat.js +2 -1
- package/dist/summaryFormat.js.map +1 -1
- package/dist/summaryManager.d.ts +0 -15
- package/dist/summaryManager.d.ts.map +1 -1
- package/dist/summaryManager.js +1 -35
- package/dist/summaryManager.js.map +1 -1
- package/lib/containerRuntime.d.ts +25 -16
- package/lib/containerRuntime.d.ts.map +1 -1
- package/lib/containerRuntime.js +131 -83
- package/lib/containerRuntime.js.map +1 -1
- package/lib/dataStoreContext.d.ts +29 -3
- package/lib/dataStoreContext.d.ts.map +1 -1
- package/lib/dataStoreContext.js +29 -4
- package/lib/dataStoreContext.js.map +1 -1
- package/lib/dataStores.d.ts +7 -3
- package/lib/dataStores.d.ts.map +1 -1
- package/lib/dataStores.js +54 -5
- package/lib/dataStores.js.map +1 -1
- package/lib/garbageCollection.d.ts +22 -2
- package/lib/garbageCollection.d.ts.map +1 -1
- package/lib/garbageCollection.js +114 -36
- package/lib/garbageCollection.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.d.ts.map +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/runningSummarizer.d.ts +3 -2
- package/lib/runningSummarizer.d.ts.map +1 -1
- package/lib/runningSummarizer.js +6 -6
- package/lib/runningSummarizer.js.map +1 -1
- package/lib/summarizer.d.ts +22 -0
- package/lib/summarizer.d.ts.map +1 -1
- package/lib/summarizer.js +135 -33
- package/lib/summarizer.js.map +1 -1
- package/lib/summarizerTypes.d.ts +1 -8
- package/lib/summarizerTypes.d.ts.map +1 -1
- package/lib/summarizerTypes.js.map +1 -1
- package/lib/summaryFormat.d.ts +1 -0
- package/lib/summaryFormat.d.ts.map +1 -1
- package/lib/summaryFormat.js +1 -0
- package/lib/summaryFormat.js.map +1 -1
- package/lib/summaryManager.d.ts +0 -15
- package/lib/summaryManager.d.ts.map +1 -1
- package/lib/summaryManager.js +1 -34
- package/lib/summaryManager.js.map +1 -1
- package/package.json +14 -14
- package/src/containerRuntime.ts +176 -93
- package/src/dataStoreContext.ts +44 -6
- package/src/dataStores.ts +84 -4
- package/src/garbageCollection.ts +137 -46
- package/src/packageVersion.ts +1 -1
- package/src/runningSummarizer.ts +12 -10
- package/src/summarizer.ts +154 -38
- package/src/summarizerTypes.ts +2 -9
- package/src/summaryFormat.ts +1 -0
- package/src/summaryManager.ts +2 -49
- package/dist/localStorageFeatureGates.d.ts +0 -13
- package/dist/localStorageFeatureGates.d.ts.map +0 -1
- package/dist/localStorageFeatureGates.js +0 -31
- package/dist/localStorageFeatureGates.js.map +0 -1
- package/lib/localStorageFeatureGates.d.ts +0 -13
- package/lib/localStorageFeatureGates.d.ts.map +0 -1
- package/lib/localStorageFeatureGates.js +0 -27
- package/lib/localStorageFeatureGates.js.map +0 -1
- package/src/localStorageFeatureGates.ts +0 -27
package/src/runningSummarizer.ts
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
import { IDisposable, ITelemetryLogger, ITelemetryProperties } from "@fluidframework/common-definitions";
|
|
7
7
|
import { assert, delay, Deferred, PromiseTimer } from "@fluidframework/common-utils";
|
|
8
|
+
import { UsageError } from "@fluidframework/container-utils";
|
|
8
9
|
import {
|
|
9
10
|
ISequencedDocumentMessage,
|
|
10
11
|
ISummaryConfiguration,
|
|
@@ -18,7 +19,6 @@ import {
|
|
|
18
19
|
ISummarizeHeuristicData,
|
|
19
20
|
ISummarizeHeuristicRunner,
|
|
20
21
|
ISummarizerOptions,
|
|
21
|
-
OnDemandSummarizeResult,
|
|
22
22
|
IOnDemandSummarizeOptions,
|
|
23
23
|
EnqueueSummarizeResult,
|
|
24
24
|
SummarizerStopReason,
|
|
@@ -408,25 +408,27 @@ export class RunningSummarizer implements IDisposable {
|
|
|
408
408
|
}
|
|
409
409
|
|
|
410
410
|
/** {@inheritdoc (ISummarizer:interface).summarizeOnDemand} */
|
|
411
|
-
public summarizeOnDemand(
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
411
|
+
public summarizeOnDemand(
|
|
412
|
+
resultsBuilder: SummarizeResultBuilder = new SummarizeResultBuilder(),
|
|
413
|
+
{
|
|
414
|
+
reason,
|
|
415
|
+
...options
|
|
416
|
+
}: IOnDemandSummarizeOptions): ISummarizeResults {
|
|
415
417
|
if (this.stopping) {
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
return failBuilder.build();
|
|
418
|
+
resultsBuilder.fail("RunningSummarizer stopped or disposed", undefined);
|
|
419
|
+
return resultsBuilder.build();
|
|
419
420
|
}
|
|
420
421
|
// Check for concurrent summary attempts. If one is found,
|
|
421
422
|
// return a promise that caller can await before trying again.
|
|
422
423
|
if (this.summarizingLock !== undefined) {
|
|
423
424
|
// The heuristics are blocking concurrent summarize attempts.
|
|
424
|
-
|
|
425
|
+
throw new UsageError("Attempted to run an already-running summarizer on demand");
|
|
425
426
|
}
|
|
426
427
|
const result = this.trySummarizeOnce(
|
|
427
428
|
{ summarizeReason: `onDemand/${reason}` },
|
|
428
429
|
options,
|
|
429
|
-
this.cancellationToken
|
|
430
|
+
this.cancellationToken,
|
|
431
|
+
resultsBuilder);
|
|
430
432
|
return result;
|
|
431
433
|
}
|
|
432
434
|
|
package/src/summarizer.ts
CHANGED
|
@@ -6,16 +6,23 @@
|
|
|
6
6
|
import { EventEmitter } from "events";
|
|
7
7
|
import { Deferred } from "@fluidframework/common-utils";
|
|
8
8
|
import { ITelemetryLogger } from "@fluidframework/common-definitions";
|
|
9
|
+
import { ILoader, LoaderHeader } from "@fluidframework/container-definitions";
|
|
10
|
+
import { UsageError } from "@fluidframework/container-utils";
|
|
11
|
+
import { DriverHeader } from "@fluidframework/driver-definitions";
|
|
12
|
+
import { requestFluidObject } from "@fluidframework/runtime-utils";
|
|
9
13
|
import { ChildLogger, IFluidErrorBase, LoggingError, wrapErrorAndLog } from "@fluidframework/telemetry-utils";
|
|
10
14
|
import {
|
|
15
|
+
FluidObject,
|
|
11
16
|
IFluidHandleContext,
|
|
12
17
|
IFluidHandle,
|
|
18
|
+
IRequest,
|
|
13
19
|
} from "@fluidframework/core-interfaces";
|
|
14
20
|
import {
|
|
15
21
|
ISequencedDocumentMessage,
|
|
16
22
|
ISummaryConfiguration,
|
|
17
23
|
} from "@fluidframework/protocol-definitions";
|
|
18
24
|
import { ICancellableSummarizerController } from "./runWhileConnectedCoordinator";
|
|
25
|
+
import { summarizerClientType } from "./summarizerClientElection";
|
|
19
26
|
import { SummaryCollection } from "./summaryCollection";
|
|
20
27
|
import { SummarizerHandle } from "./summarizerHandle";
|
|
21
28
|
import { RunningSummarizer } from "./runningSummarizer";
|
|
@@ -28,6 +35,7 @@ import {
|
|
|
28
35
|
SummarizerStopReason,
|
|
29
36
|
} from "./summarizerTypes";
|
|
30
37
|
import { SummarizeHeuristicData } from "./summarizerHeuristics";
|
|
38
|
+
import { SummarizeResultBuilder } from "./summaryGenerator";
|
|
31
39
|
import { IConnectableRuntime } from ".";
|
|
32
40
|
|
|
33
41
|
const summarizingError = "summarizingError";
|
|
@@ -67,6 +75,7 @@ export class Summarizer extends EventEmitter implements ISummarizer {
|
|
|
67
75
|
private systemOpListener?: (op: ISequencedDocumentMessage) => void;
|
|
68
76
|
private opListener?: (error: any, op: ISequencedDocumentMessage) => void;
|
|
69
77
|
private _disposed: boolean = false;
|
|
78
|
+
private starting: boolean = false;
|
|
70
79
|
|
|
71
80
|
private readonly innerHandle: IFluidHandle<this>;
|
|
72
81
|
|
|
@@ -94,6 +103,40 @@ export class Summarizer extends EventEmitter implements ISummarizer {
|
|
|
94
103
|
this.innerHandle = new SummarizerHandle(this, url, handleContext);
|
|
95
104
|
}
|
|
96
105
|
|
|
106
|
+
/**
|
|
107
|
+
* Creates a Summarizer and its underlying client.
|
|
108
|
+
* Note that different implementations of ILoader will handle the URL differently.
|
|
109
|
+
* ILoader provided by a ContainerRuntime is a RelativeLoader, which will treat URL's
|
|
110
|
+
* starting with "/" as relative to the Container. The general ILoader
|
|
111
|
+
* interface will expect an absolute URL and will not handle "/".
|
|
112
|
+
* @param loader - the loader that resolves the request
|
|
113
|
+
* @param url - the URL used to resolve the container
|
|
114
|
+
*/
|
|
115
|
+
public static async create(
|
|
116
|
+
loader: ILoader,
|
|
117
|
+
url: string): Promise<ISummarizer> {
|
|
118
|
+
const request: IRequest = {
|
|
119
|
+
headers: {
|
|
120
|
+
[LoaderHeader.cache]: false,
|
|
121
|
+
[LoaderHeader.clientDetails]: {
|
|
122
|
+
capabilities: { interactive: false },
|
|
123
|
+
type: summarizerClientType,
|
|
124
|
+
},
|
|
125
|
+
[DriverHeader.summarizingClient]: true,
|
|
126
|
+
[LoaderHeader.reconnect]: false,
|
|
127
|
+
},
|
|
128
|
+
url,
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
const resolvedContainer = await loader.resolve(request);
|
|
132
|
+
const fluidObject =
|
|
133
|
+
await requestFluidObject<FluidObject<ISummarizer>>(resolvedContainer, { url: "_summarizer" });
|
|
134
|
+
if (fluidObject.ISummarizer === undefined) {
|
|
135
|
+
throw new UsageError("Fluid object does not implement ISummarizer");
|
|
136
|
+
}
|
|
137
|
+
return fluidObject.ISummarizer;
|
|
138
|
+
}
|
|
139
|
+
|
|
97
140
|
public async run(
|
|
98
141
|
onBehalfOf: string,
|
|
99
142
|
options?: Readonly<Partial<ISummarizerOptions>>): Promise<SummarizerStopReason> {
|
|
@@ -120,13 +163,6 @@ export class Summarizer extends EventEmitter implements ISummarizer {
|
|
|
120
163
|
private async runCore(
|
|
121
164
|
onBehalfOf: string,
|
|
122
165
|
options?: Readonly<Partial<ISummarizerOptions>>): Promise<SummarizerStopReason> {
|
|
123
|
-
// Initialize values and first ack (time is not exact)
|
|
124
|
-
this.logger.sendTelemetryEvent({
|
|
125
|
-
eventName: "RunningSummarizer",
|
|
126
|
-
onBehalfOf,
|
|
127
|
-
initSummarySeqNumber: this.runtime.deltaManager.initialSequenceNumber,
|
|
128
|
-
});
|
|
129
|
-
|
|
130
166
|
const runCoordinator: ICancellableSummarizerController = await this.runCoordinatorCreateFn(this.runtime);
|
|
131
167
|
|
|
132
168
|
// Wait for either external signal to cancel, or loss of connectivity.
|
|
@@ -143,10 +179,70 @@ export class Summarizer extends EventEmitter implements ISummarizer {
|
|
|
143
179
|
return runCoordinator.waitCancelled;
|
|
144
180
|
}
|
|
145
181
|
|
|
182
|
+
const runningSummarizer = await this.start(onBehalfOf, runCoordinator, options);
|
|
183
|
+
|
|
184
|
+
// Wait for either external signal to cancel, or loss of connectivity.
|
|
185
|
+
const stopReason = await stopP;
|
|
186
|
+
|
|
187
|
+
// There are two possible approaches here:
|
|
188
|
+
// 1. Propagate cancellation from this.stopDeferred to runCoordinator. This will ensure that we move to the exit
|
|
189
|
+
// faster, including breaking out of the RunningSummarizer.trySummarize() faster.
|
|
190
|
+
// We could create new coordinator and pass it to waitStop() -> trySummarizeOnce("lastSummary") flow.
|
|
191
|
+
// The con of this approach is that we might cancel active summary, and lastSummary will fail because it
|
|
192
|
+
// did not wait for ack/nack from previous summary. Plus we disregard any 429 kind of info from service
|
|
193
|
+
// that way (i.e. trySummarize() loop might have been waiting for 5 min because storage told us so).
|
|
194
|
+
// In general, it's more wasted resources.
|
|
195
|
+
// 2. We can not do it and make waitStop() do last summary only if there was no active summary. This ensures
|
|
196
|
+
// that client behaves properly (from server POV) and we do not waste resources. But, it may mean we wait
|
|
197
|
+
// substantially longer for trySummarize() retries to play out and thus this summary loop may run into
|
|
198
|
+
// conflict with new summarizer client starting on different client.
|
|
199
|
+
// As of now, #2 is implemented. It's more forward looking, as issue #7279 suggests changing design for new
|
|
200
|
+
// summarizer client to not be created until current summarizer fully moves to exit, and that would reduce
|
|
201
|
+
// cons of #2 substantially.
|
|
202
|
+
|
|
203
|
+
// Cleanup after running
|
|
204
|
+
await runningSummarizer.waitStop(!runCoordinator.cancelled /* allowLastSummary */);
|
|
205
|
+
|
|
206
|
+
// Propagate reason and ensure that if someone is waiting for cancellation token, they are moving to exit
|
|
207
|
+
runCoordinator.stop(stopReason);
|
|
208
|
+
|
|
209
|
+
return stopReason;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Put the summarizer in a started state, including creating and initializing the RunningSummarizer.
|
|
214
|
+
* The start request can come either from the SummaryManager (in the auto-summarize case) or from the user
|
|
215
|
+
* (in the on-demand case).
|
|
216
|
+
* @param onBehalfOf - ID of the client that requested that the summarizer start
|
|
217
|
+
* @param runCoordinator - cancellation token
|
|
218
|
+
* @param options - options to forward to the RunningSummarizer
|
|
219
|
+
* @returns - Promise that is fulfilled when the RunningSummarizer is ready
|
|
220
|
+
*/
|
|
221
|
+
private async start(
|
|
222
|
+
onBehalfOf: string,
|
|
223
|
+
runCoordinator: ICancellableSummarizerController,
|
|
224
|
+
options?: Readonly<Partial<ISummarizerOptions>>): Promise<RunningSummarizer> {
|
|
225
|
+
if (this.runningSummarizer) {
|
|
226
|
+
if (this.runningSummarizer.disposed) {
|
|
227
|
+
throw new UsageError("Starting a disposed summarizer");
|
|
228
|
+
}
|
|
229
|
+
return this.runningSummarizer;
|
|
230
|
+
}
|
|
231
|
+
if (this.starting) {
|
|
232
|
+
throw new UsageError("Attempting to start a summarizer that is already starting");
|
|
233
|
+
}
|
|
234
|
+
this.starting = true;
|
|
235
|
+
// Initialize values and first ack (time is not exact)
|
|
236
|
+
this.logger.sendTelemetryEvent({
|
|
237
|
+
eventName: "RunningSummarizer",
|
|
238
|
+
onBehalfOf,
|
|
239
|
+
initSummarySeqNumber: this.runtime.deltaManager.initialSequenceNumber,
|
|
240
|
+
});
|
|
241
|
+
|
|
146
242
|
// Summarizing container ID (with clientType === "summarizer")
|
|
147
243
|
const clientId = this.runtime.clientId;
|
|
148
244
|
if (clientId === undefined) {
|
|
149
|
-
throw
|
|
245
|
+
throw new UsageError("clientId should be defined if connected.");
|
|
150
246
|
}
|
|
151
247
|
|
|
152
248
|
const runningSummarizer = await RunningSummarizer.start(
|
|
@@ -172,6 +268,7 @@ export class Summarizer extends EventEmitter implements ISummarizer {
|
|
|
172
268
|
options,
|
|
173
269
|
);
|
|
174
270
|
this.runningSummarizer = runningSummarizer;
|
|
271
|
+
this.starting = false;
|
|
175
272
|
|
|
176
273
|
// Handle summary acks
|
|
177
274
|
// Note: no exceptions are thrown from handleSummaryAcks handler as it handles all exceptions
|
|
@@ -186,32 +283,7 @@ export class Summarizer extends EventEmitter implements ISummarizer {
|
|
|
186
283
|
this.opListener = (error: any, op: ISequencedDocumentMessage) => runningSummarizer.handleOp(error, op);
|
|
187
284
|
this.runtime.on("batchEnd", this.opListener);
|
|
188
285
|
|
|
189
|
-
|
|
190
|
-
const stopReason = await stopP;
|
|
191
|
-
|
|
192
|
-
// There are two possible approaches here:
|
|
193
|
-
// 1. Propagate cancellation from this.stopDeferred to runCoordinator. This will ensure that we move to the exit
|
|
194
|
-
// faster, including breaking out of the RunningSummarizer.trySummarize() faster.
|
|
195
|
-
// We could create new coordinator and pass it to waitStop() -> trySummarizeOnce("lastSummary") flow.
|
|
196
|
-
// The con of this approach is that we might cancel active summary, and lastSummary will fail because it
|
|
197
|
-
// did not wait for ack/nack from previous summary. Plus we disregard any 429 kind of info from service
|
|
198
|
-
// that way (i.e. trySummarize() loop might have been waiting for 5 min because storage told us so).
|
|
199
|
-
// In general, it's more wasted resources.
|
|
200
|
-
// 2. We can not do it and make waitStop() do last summary only if there was no active summary. This ensures
|
|
201
|
-
// that client behaves properly (from server POV) and we do not waste resources. But, it may mean we wait
|
|
202
|
-
// substantially longer for trySummarize() retries to play out and thus this summary loop may run into
|
|
203
|
-
// conflict with new summarizer client starting on different client.
|
|
204
|
-
// As of now, #2 is implemented. It's more forward looking, as issue #7279 suggests changing design for new
|
|
205
|
-
// summarizer client to not be created until current summarizer fully moves to exit, and that would reduce
|
|
206
|
-
// cons of #2 substantially.
|
|
207
|
-
|
|
208
|
-
// Cleanup after running
|
|
209
|
-
await runningSummarizer.waitStop(!runCoordinator.cancelled /* allowLastSummary */);
|
|
210
|
-
|
|
211
|
-
// Propagate reason and ensure that if someone is waiting for cancellation token, they are moving to exit
|
|
212
|
-
runCoordinator.stop(stopReason);
|
|
213
|
-
|
|
214
|
-
return stopReason;
|
|
286
|
+
return runningSummarizer;
|
|
215
287
|
}
|
|
216
288
|
|
|
217
289
|
/**
|
|
@@ -238,15 +310,59 @@ export class Summarizer extends EventEmitter implements ISummarizer {
|
|
|
238
310
|
}
|
|
239
311
|
|
|
240
312
|
public readonly summarizeOnDemand: ISummarizer["summarizeOnDemand"] = (...args) => {
|
|
241
|
-
|
|
242
|
-
|
|
313
|
+
try {
|
|
314
|
+
if (this._disposed || this.runningSummarizer?.disposed) {
|
|
315
|
+
throw new UsageError("Summarizer is already disposed.");
|
|
316
|
+
}
|
|
317
|
+
if (this.runtime.summarizerClientId !== undefined &&
|
|
318
|
+
this.runtime.summarizerClientId !== this.runtime.clientId) {
|
|
319
|
+
// If there is an elected summarizer, and it's not this one, don't allow on-demand summary.
|
|
320
|
+
// This is to prevent the on-demand summary and heuristic-based summary from stepping on
|
|
321
|
+
// each other.
|
|
322
|
+
throw new UsageError("On-demand summary attempted while an elected summarizer is present");
|
|
323
|
+
}
|
|
324
|
+
const builder = new SummarizeResultBuilder();
|
|
325
|
+
if (this.runningSummarizer) {
|
|
326
|
+
// Summarizer is already running. Go ahead and start.
|
|
327
|
+
return this.runningSummarizer.summarizeOnDemand(builder, ...args);
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
// Summarizer isn't running, so we need to start it, which is an async operation.
|
|
331
|
+
// Manage the promise related to creating the cancellation token here.
|
|
332
|
+
// The promises related to starting, summarizing,
|
|
333
|
+
// and submitting are communicated to the caller through the results builder.
|
|
334
|
+
const coordinatorCreateP = this.runCoordinatorCreateFn(this.runtime);
|
|
335
|
+
|
|
336
|
+
coordinatorCreateP.then((runCoordinator) => {
|
|
337
|
+
// Successully created the cancellation token. Start the summarizer.
|
|
338
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
339
|
+
const startP = this.start(this.runtime.clientId!, runCoordinator, { disableHeuristics: true });
|
|
340
|
+
startP.then(async (runningSummarizer) => {
|
|
341
|
+
// Successfully started the summarizer. Run it.
|
|
342
|
+
runningSummarizer.summarizeOnDemand(builder, ...args);
|
|
343
|
+
// Wait for a command to stop or loss of connectivity before tearing down the summarizer and client.
|
|
344
|
+
const stopReason = await Promise.race([this.stopDeferred.promise, runCoordinator.waitCancelled]);
|
|
345
|
+
await runningSummarizer.waitStop(false);
|
|
346
|
+
runCoordinator.stop(stopReason);
|
|
347
|
+
this.dispose();
|
|
348
|
+
this.runtime.closeFn();
|
|
349
|
+
}).catch((reason) => {
|
|
350
|
+
builder.fail("Failed to start summarizer", reason);
|
|
351
|
+
});
|
|
352
|
+
}).catch((reason) => {
|
|
353
|
+
builder.fail("Failed to create cancellation token", reason);
|
|
354
|
+
});
|
|
355
|
+
|
|
356
|
+
return builder.build();
|
|
357
|
+
}
|
|
358
|
+
catch (error) {
|
|
359
|
+
throw SummarizingWarning.wrap(error, "summarizerRun", false /* logged */, this.logger);
|
|
243
360
|
}
|
|
244
|
-
return this.runningSummarizer.summarizeOnDemand(...args);
|
|
245
361
|
};
|
|
246
362
|
|
|
247
363
|
public readonly enqueueSummarize: ISummarizer["enqueueSummarize"] = (...args) => {
|
|
248
364
|
if (this._disposed || this.runningSummarizer === undefined || this.runningSummarizer.disposed) {
|
|
249
|
-
throw
|
|
365
|
+
throw new UsageError("Summarizer is not running or already disposed.");
|
|
250
366
|
}
|
|
251
367
|
return this.runningSummarizer.enqueueSummarize(...args);
|
|
252
368
|
};
|
package/src/summarizerTypes.ts
CHANGED
|
@@ -238,14 +238,6 @@ export interface ISummarizeResults {
|
|
|
238
238
|
readonly receivedSummaryAckOrNack: Promise<SummarizeResultPart<IAckSummaryResult, INackSummaryResult>>;
|
|
239
239
|
}
|
|
240
240
|
|
|
241
|
-
export type OnDemandSummarizeResult = (ISummarizeResults & {
|
|
242
|
-
/** Indicates that an already running summarize attempt does not exist. */
|
|
243
|
-
readonly alreadyRunning?: undefined;
|
|
244
|
-
}) | {
|
|
245
|
-
/** Resolves when an already running summarize attempt completes. */
|
|
246
|
-
readonly alreadyRunning: Promise<void>;
|
|
247
|
-
};
|
|
248
|
-
|
|
249
241
|
export type EnqueueSummarizeResult = (ISummarizeResults & {
|
|
250
242
|
/**
|
|
251
243
|
* Indicates that another summarize attempt is not already enqueued,
|
|
@@ -297,6 +289,7 @@ export interface ISummarizerEvents extends IEvent {
|
|
|
297
289
|
export interface ISummarizer extends
|
|
298
290
|
IEventProvider<ISummarizerEvents>, IFluidLoadable, Partial<IProvideSummarizer>{
|
|
299
291
|
stop(reason: SummarizerStopReason): void;
|
|
292
|
+
|
|
300
293
|
run(onBehalfOf: string, options?: Readonly<Partial<ISummarizerOptions>>): Promise<SummarizerStopReason>;
|
|
301
294
|
|
|
302
295
|
/**
|
|
@@ -308,7 +301,7 @@ export interface ISummarizer extends
|
|
|
308
301
|
* that resolve as the summarize attempt progresses. They will resolve with success
|
|
309
302
|
* false if a failure is encountered.
|
|
310
303
|
*/
|
|
311
|
-
summarizeOnDemand(options: IOnDemandSummarizeOptions):
|
|
304
|
+
summarizeOnDemand(options: IOnDemandSummarizeOptions): ISummarizeResults;
|
|
312
305
|
/**
|
|
313
306
|
* Enqueue an attempt to summarize after the specified sequence number.
|
|
314
307
|
* If afterSequenceNumber is provided, the summarize attempt is "enqueued"
|
package/src/summaryFormat.ts
CHANGED
|
@@ -135,6 +135,7 @@ export function getMetadataFormatVersion(metadata?: IContainerRuntimeMetadata):
|
|
|
135
135
|
return metadata?.summaryFormatVersion ?? 0;
|
|
136
136
|
}
|
|
137
137
|
|
|
138
|
+
export const aliasBlobName = ".aliases";
|
|
138
139
|
export const metadataBlobName = ".metadata";
|
|
139
140
|
export const chunksBlobName = ".chunks";
|
|
140
141
|
export const electedSummarizerBlobName = ".electedSummarizer";
|
package/src/summaryManager.ts
CHANGED
|
@@ -6,12 +6,9 @@
|
|
|
6
6
|
import { IDisposable, IEvent, IEventProvider, ITelemetryLogger } from "@fluidframework/common-definitions";
|
|
7
7
|
import { TypedEventEmitter, assert } from "@fluidframework/common-utils";
|
|
8
8
|
import { ChildLogger, PerformanceEvent } from "@fluidframework/telemetry-utils";
|
|
9
|
-
import {
|
|
10
|
-
import { LoaderHeader } from "@fluidframework/container-definitions";
|
|
11
|
-
import { DriverHeader, DriverErrorType } from "@fluidframework/driver-definitions";
|
|
12
|
-
import { requestFluidObject } from "@fluidframework/runtime-utils";
|
|
9
|
+
import { DriverErrorType } from "@fluidframework/driver-definitions";
|
|
13
10
|
import { createSummarizingWarning } from "./summarizer";
|
|
14
|
-
import { ISummarizerClientElection
|
|
11
|
+
import { ISummarizerClientElection } from "./summarizerClientElection";
|
|
15
12
|
import { IThrottler } from "./throttler";
|
|
16
13
|
import {
|
|
17
14
|
ISummarizer,
|
|
@@ -371,47 +368,3 @@ export class SummaryManager extends TypedEventEmitter<ISummaryManagerEvents> imp
|
|
|
371
368
|
this._disposed = true;
|
|
372
369
|
}
|
|
373
370
|
}
|
|
374
|
-
|
|
375
|
-
export interface ISummarizerRequestOptions {
|
|
376
|
-
cache: boolean,
|
|
377
|
-
reconnect: boolean,
|
|
378
|
-
summarizingClient: boolean,
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
/**
|
|
382
|
-
* Forms a function that will request a Summarizer.
|
|
383
|
-
* @param loaderRouter - the loader acting as an IFluidRouter
|
|
384
|
-
* @param lastSequenceNumber - the last sequence number (e.g., from DeltaManager)
|
|
385
|
-
* @param cache - use cache to retrieve summarizer
|
|
386
|
-
* @param summarizingClient - is summarizer client
|
|
387
|
-
* @param reconnect - can reconnect on connection loss
|
|
388
|
-
*/
|
|
389
|
-
export const formRequestSummarizerFn = (
|
|
390
|
-
loaderRouter: IFluidRouter,
|
|
391
|
-
lastSequenceNumber: number,
|
|
392
|
-
{ cache, reconnect, summarizingClient }: ISummarizerRequestOptions,
|
|
393
|
-
) => async () => {
|
|
394
|
-
// TODO eventually we may wish to spawn an execution context from which to run this
|
|
395
|
-
const request: IRequest = {
|
|
396
|
-
headers: {
|
|
397
|
-
[LoaderHeader.cache]: cache,
|
|
398
|
-
[LoaderHeader.clientDetails]: {
|
|
399
|
-
capabilities: { interactive: false },
|
|
400
|
-
type: summarizerClientType,
|
|
401
|
-
},
|
|
402
|
-
[DriverHeader.summarizingClient]: summarizingClient,
|
|
403
|
-
[LoaderHeader.reconnect]: reconnect,
|
|
404
|
-
[LoaderHeader.sequenceNumber]: lastSequenceNumber,
|
|
405
|
-
},
|
|
406
|
-
url: "/_summarizer",
|
|
407
|
-
};
|
|
408
|
-
|
|
409
|
-
const fluidObject = await requestFluidObject<FluidObject<ISummarizer>>(loaderRouter, request);
|
|
410
|
-
const summarizer = fluidObject.ISummarizer;
|
|
411
|
-
|
|
412
|
-
if (!summarizer) {
|
|
413
|
-
return Promise.reject(new Error("Fluid object does not implement ISummarizer"));
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
return summarizer;
|
|
417
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Helper to check if the given feature key is set in local storage.
|
|
7
|
-
* @returns the following:
|
|
8
|
-
* - true, if the key is set and the value is "1".
|
|
9
|
-
* - false, if the key is set and the value is "0".
|
|
10
|
-
* - undefined, if local storage is not available or the key is not set.
|
|
11
|
-
*/
|
|
12
|
-
export declare function getLocalStorageFeatureGate(key: string): boolean | undefined;
|
|
13
|
-
//# sourceMappingURL=localStorageFeatureGates.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"localStorageFeatureGates.d.ts","sourceRoot":"","sources":["../src/localStorageFeatureGates.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAc3E"}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*!
|
|
3
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
4
|
-
* Licensed under the MIT License.
|
|
5
|
-
*/
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.getLocalStorageFeatureGate = void 0;
|
|
8
|
-
/**
|
|
9
|
-
* Helper to check if the given feature key is set in local storage.
|
|
10
|
-
* @returns the following:
|
|
11
|
-
* - true, if the key is set and the value is "1".
|
|
12
|
-
* - false, if the key is set and the value is "0".
|
|
13
|
-
* - undefined, if local storage is not available or the key is not set.
|
|
14
|
-
*/
|
|
15
|
-
function getLocalStorageFeatureGate(key) {
|
|
16
|
-
try {
|
|
17
|
-
if (typeof localStorage === "object" && localStorage !== null) {
|
|
18
|
-
const itemValue = localStorage.getItem(key);
|
|
19
|
-
if (itemValue === "1") {
|
|
20
|
-
return true;
|
|
21
|
-
}
|
|
22
|
-
if (itemValue === "0") {
|
|
23
|
-
return false;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
catch (e) { }
|
|
28
|
-
return undefined;
|
|
29
|
-
}
|
|
30
|
-
exports.getLocalStorageFeatureGate = getLocalStorageFeatureGate;
|
|
31
|
-
//# sourceMappingURL=localStorageFeatureGates.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"localStorageFeatureGates.js","sourceRoot":"","sources":["../src/localStorageFeatureGates.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH;;;;;;GAMG;AACH,SAAgB,0BAA0B,CAAC,GAAW;IAClD,IAAI;QACA,IAAI,OAAO,YAAY,KAAK,QAAQ,IAAI,YAAY,KAAK,IAAI,EAAE;YAC3D,MAAM,SAAS,GAAG,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;YAC5C,IAAK,SAAS,KAAK,GAAG,EAAE;gBACpB,OAAO,IAAI,CAAC;aACf;YACD,IAAI,SAAS,KAAK,GAAG,EAAE;gBACnB,OAAO,KAAK,CAAC;aAChB;SACJ;KACJ;IAAC,OAAO,CAAC,EAAE,GAAE;IAEd,OAAO,SAAS,CAAC;AACrB,CAAC;AAdD,gEAcC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * Helper to check if the given feature key is set in local storage.\n * @returns the following:\n * - true, if the key is set and the value is \"1\".\n * - false, if the key is set and the value is \"0\".\n * - undefined, if local storage is not available or the key is not set.\n */\nexport function getLocalStorageFeatureGate(key: string): boolean | undefined {\n try {\n if (typeof localStorage === \"object\" && localStorage !== null) {\n const itemValue = localStorage.getItem(key);\n if (itemValue === \"1\") {\n return true;\n }\n if (itemValue === \"0\") {\n return false;\n }\n }\n } catch (e) {}\n\n return undefined;\n}\n"]}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Helper to check if the given feature key is set in local storage.
|
|
7
|
-
* @returns the following:
|
|
8
|
-
* - true, if the key is set and the value is "1".
|
|
9
|
-
* - false, if the key is set and the value is "0".
|
|
10
|
-
* - undefined, if local storage is not available or the key is not set.
|
|
11
|
-
*/
|
|
12
|
-
export declare function getLocalStorageFeatureGate(key: string): boolean | undefined;
|
|
13
|
-
//# sourceMappingURL=localStorageFeatureGates.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"localStorageFeatureGates.d.ts","sourceRoot":"","sources":["../src/localStorageFeatureGates.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAc3E"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Helper to check if the given feature key is set in local storage.
|
|
7
|
-
* @returns the following:
|
|
8
|
-
* - true, if the key is set and the value is "1".
|
|
9
|
-
* - false, if the key is set and the value is "0".
|
|
10
|
-
* - undefined, if local storage is not available or the key is not set.
|
|
11
|
-
*/
|
|
12
|
-
export function getLocalStorageFeatureGate(key) {
|
|
13
|
-
try {
|
|
14
|
-
if (typeof localStorage === "object" && localStorage !== null) {
|
|
15
|
-
const itemValue = localStorage.getItem(key);
|
|
16
|
-
if (itemValue === "1") {
|
|
17
|
-
return true;
|
|
18
|
-
}
|
|
19
|
-
if (itemValue === "0") {
|
|
20
|
-
return false;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
catch (e) { }
|
|
25
|
-
return undefined;
|
|
26
|
-
}
|
|
27
|
-
//# sourceMappingURL=localStorageFeatureGates.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"localStorageFeatureGates.js","sourceRoot":"","sources":["../src/localStorageFeatureGates.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;GAMG;AACH,MAAM,UAAU,0BAA0B,CAAC,GAAW;IAClD,IAAI;QACA,IAAI,OAAO,YAAY,KAAK,QAAQ,IAAI,YAAY,KAAK,IAAI,EAAE;YAC3D,MAAM,SAAS,GAAG,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;YAC5C,IAAK,SAAS,KAAK,GAAG,EAAE;gBACpB,OAAO,IAAI,CAAC;aACf;YACD,IAAI,SAAS,KAAK,GAAG,EAAE;gBACnB,OAAO,KAAK,CAAC;aAChB;SACJ;KACJ;IAAC,OAAO,CAAC,EAAE,GAAE;IAEd,OAAO,SAAS,CAAC;AACrB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * Helper to check if the given feature key is set in local storage.\n * @returns the following:\n * - true, if the key is set and the value is \"1\".\n * - false, if the key is set and the value is \"0\".\n * - undefined, if local storage is not available or the key is not set.\n */\nexport function getLocalStorageFeatureGate(key: string): boolean | undefined {\n try {\n if (typeof localStorage === \"object\" && localStorage !== null) {\n const itemValue = localStorage.getItem(key);\n if (itemValue === \"1\") {\n return true;\n }\n if (itemValue === \"0\") {\n return false;\n }\n }\n } catch (e) {}\n\n return undefined;\n}\n"]}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Helper to check if the given feature key is set in local storage.
|
|
8
|
-
* @returns the following:
|
|
9
|
-
* - true, if the key is set and the value is "1".
|
|
10
|
-
* - false, if the key is set and the value is "0".
|
|
11
|
-
* - undefined, if local storage is not available or the key is not set.
|
|
12
|
-
*/
|
|
13
|
-
export function getLocalStorageFeatureGate(key: string): boolean | undefined {
|
|
14
|
-
try {
|
|
15
|
-
if (typeof localStorage === "object" && localStorage !== null) {
|
|
16
|
-
const itemValue = localStorage.getItem(key);
|
|
17
|
-
if (itemValue === "1") {
|
|
18
|
-
return true;
|
|
19
|
-
}
|
|
20
|
-
if (itemValue === "0") {
|
|
21
|
-
return false;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
} catch (e) {}
|
|
25
|
-
|
|
26
|
-
return undefined;
|
|
27
|
-
}
|