/*! * Copyright (c) Microsoft Corporation and contributors. All rights reserved. * Licensed under the MIT License. */ import { TypedEventEmitter } from "@fluid-internal/client-utils"; import type { ISummarizerEvents } from "@fluidframework/container-runtime-definitions/internal"; import type { IDisposable, IEvent, IEventProvider, ITelemetryBaseLogger } from "@fluidframework/core-interfaces"; import type { IThrottler } from "../throttler.js"; import type { ISummarizerClientElection } from "./summarizerClientElection.js"; import type { IEnqueueSummarizeOptions, IOnDemandSummarizeOptions, ISummarizer } from "./summarizerTypes.js"; import type { SummaryCollection } from "./summaryCollection.js"; import type { EnqueueSummarizeResult, ISummarizeResults } from "./summaryDelayLoadedModule/index.js"; export declare enum SummaryManagerState { Off = 0, Starting = 1, Running = 2, Stopping = 3 } export interface IConnectedEvents extends IEvent { (event: "connected", listener: (clientId: string) => void): any; (event: "disconnected", listener: () => void): any; } /** * IConnectedState describes an object that SummaryManager can watch to observe connection/disconnection. * * Under current implementation, its role will be fulfilled by the ContainerRuntime, but this could be replaced * with anything else that fulfills the contract if we want to shift the layer that the SummaryManager lives at. */ export interface IConnectedState extends IEventProvider { readonly connected: boolean; /** * Under current implementation this is undefined if we've never connected, otherwise it's the clientId from our * latest connection (even if we've since disconnected!). Although this happens to be the behavior we want in * SummaryManager, I suspect that globally we may eventually want to modify this behavior (e.g. make clientId * undefined while disconnected). To protect against this, let's assume this field can't be trusted while * disconnected and instead separately track "latest clientId" in SummaryManager. */ readonly clientId: string | undefined; } export interface ISummaryManagerConfig { initialDelayMs: number; opsToBypassInitialDelay: number; } /** * SummaryManager is created by parent container (i.e. interactive container with clientType !== "summarizer") only. * It observes changes in calculated summarizer and reacts to changes by either creating summarizer client or * stopping existing summarizer client. */ export declare class SummaryManager extends TypedEventEmitter implements IDisposable { private readonly clientElection; private readonly connectedState; private readonly summaryCollection; /** * Creates summarizer by asking interactive container to spawn summarizing container and * get back its Summarizer instance. */ private readonly createSummarizerFn; private readonly startThrottler; private readonly logger; private readonly opsToBypassInitialDelay; private readonly initialDelayMs; private latestClientId; private state; private summarizer?; private pendingStopReason?; private _disposed; private summarizerStopTimeout?; /** * Monotonically increasing counter that tracks summarizer lifecycle generations. * Incremented each time {@link cleanupAfterSummarizerStop} runs. Used by the * promise chain in {@link startSummarization} to detect that cleanup has already * been performed by another path (e.g. the stop timeout), so it can skip * redundant cleanup that would corrupt the state machine. */ private summarizerGeneration; get disposed(): boolean; get currentState(): SummaryManagerState; constructor(clientElection: ISummarizerClientElection, connectedState: IConnectedState, summaryCollection: Pick, parentLogger: ITelemetryBaseLogger, /** * Creates summarizer by asking interactive container to spawn summarizing container and * get back its Summarizer instance. */ createSummarizerFn: () => Promise, startThrottler: IThrottler, { initialDelayMs, opsToBypassInitialDelay, }?: Readonly>); /** * Until start is called, the SummaryManager won't begin attempting to start summarization. This ensures there's * a window between construction and starting where the caller can attach listeners. */ start(): void; private readonly handleConnected; private readonly handleDisconnected; private static readonly isStartingOrRunning; private getShouldSummarizeState; private readonly refreshSummarizer; private startSummarization; private cleanupAfterSummarizerStop; private stop; /** * Implements initial delay before creating summarizer * @returns `true`, if creation is delayed due to heuristics (not many ops to summarize). * `false` if summarizer should start immediately due to too many unsummarized ops. */ private delayBeforeCreatingSummarizer; summarizeOnDemand(options: IOnDemandSummarizeOptions): ISummarizeResults; enqueueSummarize(options: IEnqueueSummarizeOptions): EnqueueSummarizeResult; dispose(): void; private readonly forwardedEventsCleanup; private setupForwardedEvents; private cleanupForwardedEvents; } //# sourceMappingURL=summaryManager.d.ts.map