/*! * Copyright (c) Microsoft Corporation and contributors. All rights reserved. * Licensed under the MIT License. */ import type { IDisposable, ITelemetryBaseLogger } from "@fluidframework/core-interfaces"; import type { FluidDataStoreContext, LocalFluidDataStoreContext } from "./dataStoreContext.js"; /** * Manages the collection of data store contexts, tracking their bound/unbound state. * * @remarks * A context is "unbound" when it's created locally but not yet made visible (reachable from root). * A context is "bound" once it's made locally visible, regardless of the Container's attach state. * In attached containers, binding a context immediately sends an attach op and transitions it to Attaching state. * * @internal */ export declare class DataStoreContexts implements Iterable<[string, FluidDataStoreContext]>, IDisposable { /** * Set of IDs for contexts that are unbound (not yet made locally visible). * These contexts exist locally but aren't known to other clients (even in an attached container). */ private readonly notBoundContexts; /** * Map of all data store contexts (both bound and unbound). */ private readonly _contexts; /** * List of pending context waiting either to be bound or to arrive from another client. * This covers the case where a local context has been created but not yet bound, * or the case where a client knows a store will exist (e.g. by alias) and is waiting on its creation, * so that a caller may await the deferred's promise until such a time as the context is fully ready. * This is a superset of _contexts, since contexts remain here once the Deferred resolves. */ private readonly deferredContexts; /** * Lazy disposal logic that disposes all contexts when called. */ private readonly disposeOnce; private readonly _logger; constructor(baseLogger: ITelemetryBaseLogger); [Symbol.iterator](): Iterator<[string, FluidDataStoreContext]>; get size(): number; get disposed(): boolean; readonly dispose: () => void; /** * Returns the count of unbound contexts (i.e. local-only on this client) */ notBoundLength(): number; /** * Returns true if the given ID corresponds to an unbound context. (i.e. local-only on this client) */ isNotBound(id: string): boolean; /** * Returns true if a context with the given ID exists (bound or unbound). */ has(id: string): boolean; /** * Returns the context with the given ID, or undefined if not found. * This returns both bound and unbound contexts. */ get(id: string): FluidDataStoreContext | undefined; /** * Deletes the context with the given ID from all internal maps. * @returns True if the context was found and deleted, false otherwise. */ delete(id: string): boolean; /** * Map of recently deleted contexts for diagnostic purposes for GC. * Allows retrieval of context information even after deletion for logging/telemetry. */ private readonly _recentlyDeletedContexts; /** * Returns a recently deleted context by ID, or undefined if not found. * Used for diagnostic logging for GC, when a deleted context is referenced. */ getRecentlyDeletedContext(id: string): FluidDataStoreContext | undefined; /** * Returns the unbound local context with the given ID. * @returns The unbound context, or undefined if not found or not unbound. */ getUnbound(id: string): LocalFluidDataStoreContext | undefined; /** * Adds the given context to the collection, marking it as unbound (not yet locally visible). * Asserts that no context with this ID already exists. */ addUnbound(context: LocalFluidDataStoreContext): void; /** * Get the context with the given id, once it exists locally and is attached. * e.g. If created locally, it must be bound, or if created remotely then it's fine as soon as it's sync'd in. * @param id - The id of the context to get * @param wait - If false, return undefined if the context isn't present and ready now. Otherwise, wait for it. */ getBoundOrRemoted(id: string, wait: boolean): Promise; /** * Gets or creates a deferred promise for the given context ID. * Used to allow waiting for contexts that don't exist yet. */ private ensureDeferred; /** * Marks the context with the given ID as bound (locally visible). * Removes it from the unbound set and resolves its deferred promise. */ bind(id: string): void; /** * Triggers the deferred to resolve, indicating the context is not local-only * @param id - The id of the context to resolve to */ private resolveDeferred; /** * Adds the given context to the collection as already bound or from a remote client. * This is used when: * - Adding a local context that's already been bound via the bind() method, OR * - Adding a remote context that was created by another client. * The context's deferred promise is resolved immediately. */ addBoundOrRemoted(context: FluidDataStoreContext): void; } //# sourceMappingURL=dataStoreContexts.d.ts.map