Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[For 2.20] Move ContainerRuntime class to internal scope #23341

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .changeset/better-mails-judge.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
"@fluidframework/aqueduct": minor
"@fluid-experimental/attributor": minor
"@fluidframework/container-runtime": minor
"@fluidframework/test-utils": minor
---
---
"section": legacy
---

ContainerRuntime class is no longer exported

Use `IContainerRuntime` to replace type usages and use the free function `loadContainerRuntime` to replace usages of the static method `ContainerRuntime.loadRuntime`.

See the [deprecation release note](https://github.com/microsoft/FluidFramework/releases/tag/client_v2.12.0#user-content-the-containerruntime-class-is-now-deprecated-23331) for more details.
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ export class BaseContainerRuntimeFactory extends RuntimeFactoryHelper implements
get IFluidDataStoreRegistry(): IFluidDataStoreRegistry;
instantiateFirstTime(runtime: IContainerRuntime): Promise<void>;
instantiateFromExisting(runtime: IContainerRuntime): Promise<void>;
// @deprecated
preInitialize(context: IContainerContext, existing: boolean): Promise<ContainerRuntime>;
preInitialize(context: IContainerContext, existing: boolean): Promise<IContainerRuntime & IRuntime>;
}

// @alpha
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
* Licensed under the MIT License.
*/

import type { IContainerContext } from "@fluidframework/container-definitions/internal";
import type {
IContainerContext,
IRuntime,
} from "@fluidframework/container-definitions/internal";
import {
// eslint-disable-next-line import/no-deprecated -- ContainerRuntime class to be moved to internal scope
ContainerRuntime,
FluidDataStoreRegistry,
loadContainerRuntime,
type IContainerRuntimeOptions,
} from "@fluidframework/container-runtime/internal";
import type { IContainerRuntime } from "@fluidframework/container-runtime-definitions/internal";
Expand Down Expand Up @@ -121,14 +123,11 @@ export class BaseContainerRuntimeFactory
* Called at the start of initializing a container, to create the container runtime instance.
* @param context - The context for the container being initialized
* @param existing - Whether the container already exists and is being loaded (else it's being created new just now)
*
* @deprecated This function should not be called directly, use instantiateRuntime instead.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@microsoft/fluid-cr-api -- I had marked this as deprecated to justify this break. Simplest thing is to remove the deprecation as I add the new type, as you see here.

But taking a step back, I think preInitialize, along with instantiateFirstTime and instantiateFromExisting should be protected not public. Once instantiated, this class (and base class RuntimeFactoryHelper) should only be referenced via the interface IRuntimeFactory, IMO.

If we go that direction I can leave this deprecated and do a follow-up PR to deprecate the others, and then in 2.30 switch them all to protected. Maybe I'm missing something though. Thoughts?

See also the deprecation release note for when I marked this as deprecated.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i would only leave it deprecated if you plan follow up and finish it, otherwise i'd just file a bug, but let the person who takes it on do the deprecation

*/
public async preInitialize(
context: IContainerContext,
existing: boolean,
// eslint-disable-next-line import/no-deprecated -- ContainerRuntime class to be moved to internal scope
): Promise<ContainerRuntime> {
): Promise<IContainerRuntime & IRuntime> {
const scope: Partial<IProvideFluidDependencySynthesizer> = context.scope;
if (this.dependencyContainer) {
const dc = new DependencyContainer<FluidObject>(
Expand All @@ -138,8 +137,7 @@ export class BaseContainerRuntimeFactory
scope.IFluidDependencySynthesizer = dc;
}

// eslint-disable-next-line import/no-deprecated -- ContainerRuntime class to be moved to internal scope
return ContainerRuntime.loadRuntime({
return loadContainerRuntime({
context,
existing,
runtimeOptions: this.runtimeOptions,
Expand Down
7 changes: 0 additions & 7 deletions packages/framework/attributor/src/mixinAttributor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
*/

import { type IContainerContext } from "@fluidframework/container-definitions/internal";
// eslint-disable-next-line import/no-deprecated -- ContainerRuntime class to be moved to internal scope
import { ContainerRuntime } from "@fluidframework/container-runtime/internal";
import type { IContainerRuntimeOptions } from "@fluidframework/container-runtime/internal";
import { type IContainerRuntime } from "@fluidframework/container-runtime-definitions/internal";
Expand Down Expand Up @@ -53,9 +52,7 @@ export async function getRuntimeAttributor(
* @internal
*/
export const mixinAttributor = (
// eslint-disable-next-line import/no-deprecated -- ContainerRuntime class to be moved to internal scope
Base: typeof ContainerRuntime = ContainerRuntime,
// eslint-disable-next-line import/no-deprecated -- ContainerRuntime class to be moved to internal scope
): typeof ContainerRuntime =>
class ContainerRuntimeWithAttributor extends Base {
public static async loadRuntime(params: {
Expand All @@ -64,14 +61,12 @@ export const mixinAttributor = (
existing: boolean;
runtimeOptions?: IContainerRuntimeOptions;
containerScope?: FluidObject;
// eslint-disable-next-line import/no-deprecated -- ContainerRuntime class to be moved to internal scope
containerRuntimeCtor?: typeof ContainerRuntime;
/**
* @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
*/
requestHandler?: (request: IRequest, runtime: IContainerRuntime) => Promise<IResponse>;
provideEntryPoint: (containerRuntime: IContainerRuntime) => Promise<FluidObject>;
// eslint-disable-next-line import/no-deprecated -- ContainerRuntime class to be moved to internal scope
}): Promise<ContainerRuntime> {
const {
context,
Expand All @@ -81,7 +76,6 @@ export const mixinAttributor = (
provideEntryPoint,
runtimeOptions,
containerScope,
// eslint-disable-next-line import/no-deprecated -- ContainerRuntime class to be moved to internal scope
containerRuntimeCtor = ContainerRuntimeWithAttributor as unknown as typeof ContainerRuntime,
} = params;

Expand Down Expand Up @@ -129,5 +123,4 @@ export const mixinAttributor = (

return runtime;
}
// eslint-disable-next-line import/no-deprecated -- ContainerRuntime class to be moved to internal scope
} as unknown as typeof ContainerRuntime;
Original file line number Diff line number Diff line change
Expand Up @@ -32,153 +32,6 @@ export enum ContainerMessageType {
Rejoin = "rejoin"
}

// @alpha @deprecated
export class ContainerRuntime extends TypedEventEmitter<IContainerRuntimeEvents> implements IContainerRuntime, IRuntime, ISummarizerRuntime, ISummarizerInternalsProvider, IProvideFluidHandleContext {
protected constructor(context: IContainerContext, registry: IFluidDataStoreRegistry, metadata: IContainerRuntimeMetadata | undefined, electedSummarizerData: ISerializedElection | undefined, chunks: [string, string[]][], dataStoreAliasMap: [string, string][], runtimeOptions: Readonly<Required<IContainerRuntimeOptions>>, containerScope: FluidObject, baseLogger: ITelemetryBaseLogger, existing: boolean, blobManagerSnapshot: IBlobManagerLoadInfo, _storage: IDocumentStorageService, createIdCompressor: () => Promise<IIdCompressor & IIdCompressorCore>, documentsSchemaController: DocumentsSchemaController, featureGatesForTelemetry: Record<string, boolean | number | undefined>, provideEntryPoint: (containerRuntime: IContainerRuntime) => Promise<FluidObject>, requestHandler?: ((request: IRequest, runtime: IContainerRuntime) => Promise<IResponse>) | undefined, summaryConfiguration?: ISummaryConfiguration, recentBatchInfo?: [number, string][]);
// (undocumented)
protected addContainerStateToSummary(summaryTree: ISummaryTreeWithStats, fullTree: boolean, trackState: boolean, telemetryContext?: ITelemetryContext): void;
addedGCOutboundRoute(fromPath: string, toPath: string, messageTimestampMs?: number): void;
// (undocumented)
get attachState(): AttachState;
// (undocumented)
readonly baseLogger: ITelemetryBaseLogger;
// (undocumented)
readonly clientDetails: IClientDetails;
// (undocumented)
get clientId(): string | undefined;
// (undocumented)
readonly closeFn: (error?: ICriticalContainerError) => void;
collectGarbage(options: {
logger?: ITelemetryLoggerExt;
runSweep?: boolean;
fullGC?: boolean;
}, telemetryContext?: ITelemetryContext): Promise<IGCStats | undefined>;
// (undocumented)
get connected(): boolean;
// (undocumented)
get containerRuntime(): this;
// (undocumented)
createDataStore(pkg: Readonly<string | string[]>, loadingGroupId?: string): Promise<IDataStore>;
// @deprecated (undocumented)
_createDataStoreWithProps(pkg: Readonly<string | string[]>, props?: any): Promise<IDataStore>;
// (undocumented)
createDetachedDataStore(pkg: Readonly<string[]>, loadingGroupId?: string): IFluidDataStoreContextDetached;
createSummary(blobRedirectTable?: Map<string, string>, telemetryContext?: ITelemetryContext): ISummaryTree;
// (undocumented)
deleteChildSummarizerNode(id: string): void;
deleteSweepReadyNodes(sweepReadyRoutes: readonly string[]): readonly string[];
get deltaManager(): IDeltaManager<ISequencedDocumentMessage, IDocumentMessage>;
// (undocumented)
dispose(error?: Error): void;
// (undocumented)
get disposed(): boolean;
// (undocumented)
readonly disposeFn: (error?: ICriticalContainerError) => void;
// (undocumented)
enqueueSummarize(options: IEnqueueSummarizeOptions): EnqueueSummarizeResult;
ensureNoDataModelChanges<T>(callback: () => T): T;
// (undocumented)
get flushMode(): FlushMode;
// @deprecated
get gcThrowOnTombstoneUsage(): boolean;
// @deprecated
get gcTombstoneEnforcementAllowed(): boolean;
generateDocumentUniqueId(): string | (number & {
readonly SessionUnique: "cea55054-6b82-4cbf-ad19-1fa645ea3b3e";
} & {
readonly OpNormalized: "9209432d-a959-4df7-b2ad-767ead4dbcae";
});
// (undocumented)
readonly getAbsoluteUrl: (relativeUrl: string) => Promise<string | undefined>;
getAliasedDataStoreEntryPoint(alias: string): Promise<IFluidHandle<FluidObject> | undefined>;
// (undocumented)
getAudience(): IAudience;
// (undocumented)
getCreateChildSummarizerNodeFn(id: string, createParam: CreateChildSummarizerNodeParam): (summarizeInternal: SummarizeInternalFn, getGCDataFn: (fullGC?: boolean) => Promise<IGarbageCollectionData>) => ISummarizerNodeWithGC;
getCurrentReferenceTimestampMs(): number | undefined;
getEntryPoint(): Promise<FluidObject>;
getGCData(fullGC?: boolean): Promise<IGarbageCollectionData>;
getGCNodePackagePath(nodePath: string): Promise<readonly string[] | undefined>;
getNodeType(nodePath: string): GCNodeType;
// (undocumented)
getPendingLocalState(props?: IGetPendingLocalStateProps): unknown;
// (undocumented)
getQuorum(): IQuorumClients;
getSnapshotForLoadingGroupId(loadingGroupIds: string[], pathParts: string[]): Promise<{
snapshotTree: ISnapshotTree;
sequenceNumber: number;
}>;
get idCompressor(): (IIdCompressor & IIdCompressorCore) | undefined;
// (undocumented)
get idCompressorMode(): IdCompressorMode;
// (undocumented)
get IFluidDataStoreRegistry(): IFluidDataStoreRegistry;
// (undocumented)
get IFluidHandleContext(): IFluidHandleContext;
get isDirty(): boolean;
protected _loadIdCompressor: Promise<void> | undefined;
static loadRuntime(params: {
context: IContainerContext;
registryEntries: NamedFluidDataStoreRegistryEntries;
existing: boolean;
runtimeOptions?: IContainerRuntimeOptions;
containerScope?: FluidObject;
containerRuntimeCtor?: typeof ContainerRuntime;
requestHandler?: (request: IRequest, runtime: IContainerRuntime) => Promise<IResponse>;
provideEntryPoint: (containerRuntime: IContainerRuntime) => Promise<FluidObject>;
}): Promise<ContainerRuntime>;
// (undocumented)
makeLocallyVisible(): void;
// (undocumented)
notifyOpReplay(message: ISequencedDocumentMessage): Promise<void>;
// (undocumented)
onSchemaChange(schema: IDocumentSchemaCurrent): void;
// (undocumented)
readonly options: Record<string | number, any>;
orderSequentially<T>(callback: () => T): T;
process({ ...messageCopy }: ISequencedDocumentMessage, local: boolean): void;
// (undocumented)
processSignal(message: ISignalMessage, local: boolean): void;
refreshLatestSummaryAck(options: IRefreshSummaryAckOptions): Promise<void>;
resolveHandle(request: IRequest): Promise<IResponse>;
// (undocumented)
get scope(): FluidObject;
get sessionSchema(): {
explicitSchemaControl?: true | undefined;
compressionLz4?: true | undefined;
idCompressorMode?: IdCompressorMode;
opGroupingEnabled?: true | undefined;
disallowedVersions?: string[] | undefined;
};
// (undocumented)
setAttachState(attachState: AttachState.Attaching | AttachState.Attached): void;
// (undocumented)
setChannelDirty(address: string): void;
// (undocumented)
setConnectionState(connected: boolean, clientId?: string): void;
// (undocumented)
get storage(): IDocumentStorageService;
// (undocumented)
submitMessage(type: ContainerMessageType.FluidDataStoreOp | ContainerMessageType.Alias | ContainerMessageType.Attach, contents: any, localOpMetadata?: unknown): void;
submitSignal(type: string, content: unknown, targetClientId?: string): void;
submitSummary(options: ISubmitSummaryOptions): Promise<SubmitSummaryResult>;
summarize(options: {
fullTree?: boolean;
trackState?: boolean;
summaryLogger?: ITelemetryLoggerExt;
runGC?: boolean;
fullGC?: boolean;
runSweep?: boolean;
}): Promise<ISummaryTreeWithStats>;
// (undocumented)
summarizeOnDemand(options: IOnDemandSummarizeOptions): ISummarizeResults;
get summarizerClientId(): string | undefined;
updateTombstonedRoutes(tombstonedRoutes: readonly string[]): void;
updateUsedRoutes(usedRoutes: readonly string[]): void;
// (undocumented)
uploadBlob(blob: ArrayBufferLike, signal?: AbortSignal): Promise<IFluidHandleInternal<ArrayBufferLike>>;
}

// @alpha
export const currentDocumentVersionSchema = 1;

Expand Down
6 changes: 1 addition & 5 deletions packages/runtime/container-runtime/src/containerRuntime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -847,11 +847,7 @@ export async function loadContainerRuntime(
* Represents the runtime of the container. Contains helper functions/state of the container.
* It will define the store level mappings.
*
* @deprecated To be removed from the Legacy-Alpha API in version 2.20.0.
* Use the loadContainerRuntime function and interfaces IContainerRuntime / IRuntime instead.
*
* @legacy
* @alpha
* @internal
*/
export class ContainerRuntime
extends TypedEventEmitter<IContainerRuntimeEvents>
Expand Down
2 changes: 0 additions & 2 deletions packages/test/test-service-load/src/loadTestDataStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
} from "@fluidframework/aqueduct/internal";
import { ILoaderOptions } from "@fluidframework/container-definitions/internal";
import {
// eslint-disable-next-line import/no-deprecated -- ContainerRuntime class to be moved to internal scope
ContainerRuntime,
IContainerRuntimeOptions,
} from "@fluidframework/container-runtime/internal";
Expand Down Expand Up @@ -135,7 +134,6 @@ class LoadTestDataStoreModel {
// If we did not create the data store above, load it by getting its url.
if (gcDataStore === undefined) {
const gcDataStoreId = root.get(gcDataStoreIdKey);
// eslint-disable-next-line import/no-deprecated -- ContainerRuntime class to be moved to internal scope
const response = await (containerRuntime as ContainerRuntime).resolveHandle({
url: `/${gcDataStoreId}`,
});
Expand Down
7 changes: 0 additions & 7 deletions packages/test/test-utils/src/testContainerRuntimeFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import { IContainerContext, IRuntime } from "@fluidframework/container-definitions/internal";
import {
// eslint-disable-next-line import/no-deprecated -- ContainerRuntime class to be moved to internal scope
ContainerRuntime,
DefaultSummaryConfiguration,
type IContainerRuntimeOptionsInternal,
Expand Down Expand Up @@ -58,9 +57,7 @@ interface backCompat_ContainerRuntime {
runtimeOptions?: IContainerRuntimeOptionsInternal,
containerScope?: FluidObject,
existing?: boolean,
// eslint-disable-next-line import/no-deprecated -- ContainerRuntime class to be moved to internal scope
containerRuntimeCtor?: typeof ContainerRuntime,
// eslint-disable-next-line import/no-deprecated -- ContainerRuntime class to be moved to internal scope
): Promise<ContainerRuntime>;
}

Expand All @@ -69,7 +66,6 @@ interface backCompat_ContainerRuntime {
* @internal
*/
export const createTestContainerRuntimeFactory = (
// eslint-disable-next-line import/no-deprecated -- ContainerRuntime class to be moved to internal scope
containerRuntimeCtor: typeof ContainerRuntime,
) => {
return class extends RuntimeFactoryHelper {
Expand All @@ -92,7 +88,6 @@ export const createTestContainerRuntimeFactory = (
super();
}

// eslint-disable-next-line import/no-deprecated -- ContainerRuntime class to be moved to internal scope
public async instantiateFirstTime(runtime: ContainerRuntime): Promise<void> {
// Back-compat - old code does not return IDataStore for rootContext.attachRuntime() call!
// Thus need to leverage old API createDetachedRootDataStore() that is gone in latest releases.
Expand All @@ -111,7 +106,6 @@ export const createTestContainerRuntimeFactory = (
assert(result === "Success" || result === undefined, "success");
}

// eslint-disable-next-line import/no-deprecated -- ContainerRuntime class to be moved to internal scope
public async instantiateFromExisting(runtime: ContainerRuntime): Promise<void> {
// Validate we can load root data stores.
// We should be able to load any data store that was created in initializeFirstTime!
Expand Down Expand Up @@ -190,5 +184,4 @@ export const createTestContainerRuntimeFactory = (
* A container runtime factory that allows you to set runtime options
* @internal
*/
// eslint-disable-next-line import/no-deprecated -- ContainerRuntime class to be moved to internal scope
export const TestContainerRuntimeFactory = createTestContainerRuntimeFactory(ContainerRuntime);
Loading