Skip to content

Commit

Permalink
Make getAliasedDataStoreEntryPoint required (#17162)
Browse files Browse the repository at this point in the history
  • Loading branch information
agarwal-navin authored Sep 2, 2023
1 parent 3874d53 commit 4c3325d
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 15 deletions.
7 changes: 7 additions & 0 deletions .changeset/ripe-results-check.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@fluidframework/container-runtime-definitions": major
---

`getAliasedDataStoreEntryPoint` in `IContainerRuntime` is now required.

`getAliasedDataStoreEntryPoint` was added to `IContainerRuntime` in 2.0.0-internal.6.0 and is now required.
2 changes: 1 addition & 1 deletion api-report/container-runtime-definitions.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export interface IContainerRuntime extends IProvideFluidDataStoreRegistry, ICont
// (undocumented)
readonly flushMode: FlushMode;
getAbsoluteUrl(relativeUrl: string): Promise<string | undefined>;
getAliasedDataStoreEntryPoint?(alias: string): Promise<IFluidHandle<FluidObject> | undefined>;
getAliasedDataStoreEntryPoint(alias: string): Promise<IFluidHandle<FluidObject> | undefined>;
// @deprecated
getRootDataStore(id: string, wait?: boolean): Promise<IFluidRouter>;
readonly isDirty: boolean;
Expand Down
3 changes: 3 additions & 0 deletions packages/runtime/container-runtime-definitions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@
"RemovedInterfaceDeclaration_IDataStoreWithBindToContext_Deprecated": {
"forwardCompat": false,
"backCompat": false
},
"InterfaceDeclaration_IContainerRuntime": {
"forwardCompat": false
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export interface IContainerRuntime
* @returns - The data store's entry point (IFluidHandle) if it exists and is aliased. Returns undefined if no
* data store has been assigned the given alias.
*/
getAliasedDataStoreEntryPoint?(alias: string): Promise<IFluidHandle<FluidObject> | undefined>;
getAliasedDataStoreEntryPoint(alias: string): Promise<IFluidHandle<FluidObject> | undefined>;

/**
* Creates detached data store context. Data store initialization is considered complete
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ declare function get_old_InterfaceDeclaration_IContainerRuntime():
declare function use_current_InterfaceDeclaration_IContainerRuntime(
use: TypeOnly<current.IContainerRuntime>);
use_current_InterfaceDeclaration_IContainerRuntime(
// @ts-expect-error compatibility expected to be broken
get_old_InterfaceDeclaration_IContainerRuntime());

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,7 @@ describeFullCompat("GC Data Store Aliased Full Compat", (getTestObjectProvider)
const containerRuntime2 = mainDataStore2._context
.containerRuntime as unknown as IContainerRuntime;
assert.doesNotThrow(
async () =>
containerRuntime2.getAliasedDataStoreEntryPoint?.(alias) ??
containerRuntime2.getRootDataStore(alias),
async () => containerRuntime2.getAliasedDataStoreEntryPoint(alias),
"Aliased datastore should be root as it is aliased!",
);
summaryWithStats = await waitForSummary(container2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,7 @@ describeFullCompat("Named root data stores", (getTestObjectProvider) => {
* Gets an aliased data store with the given id. Throws an error if the data store cannot be retrieved.
*/
async function getAliasedDataStoreEntryPoint(dataObject: ITestFluidObject, id: string) {
// back-compat: Older container runtime did not have getAliasedDataStoreEntryPoint.
const dataStore = await (runtimeOf(dataObject).getAliasedDataStoreEntryPoint?.(id) ??
runtimeOf(dataObject).getRootDataStore(id, false /* wait */));
const dataStore = await runtimeOf(dataObject).getAliasedDataStoreEntryPoint(id);
if (dataStore === undefined) {
throw new Error("Could not get aliased data store");
}
Expand Down Expand Up @@ -222,11 +220,7 @@ describeFullCompat("Named root data stores", (getTestObjectProvider) => {
const datastores: IFluidRouter[] = [];
const createAliasedDataStore = async () => {
try {
const datastore = await getAliasedDataStoreEntryPoint(dataObject1, alias);
if (datastore === undefined) {
throw new Error("Aliased data store doesn't exist yet");
}
return datastore;
await getAliasedDataStoreEntryPoint(dataObject1, alias);
} catch (err) {
const newDataStore = await runtimeOf(dataObject1).createDataStore(
packageName,
Expand Down
3 changes: 1 addition & 2 deletions packages/test/test-utils/src/testContainerRuntimeFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ export const createTestContainerRuntimeFactory = (
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!
await (runtime.getAliasedDataStoreEntryPoint?.("default") ??
runtime.getRootDataStore("default"));
await runtime.getAliasedDataStoreEntryPoint("default");
}

async preInitialize(
Expand Down

0 comments on commit 4c3325d

Please sign in to comment.