Skip to content

Runtime: Expose readonly directly off the datastore runtime #24410

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

Merged
merged 28 commits into from
Apr 23, 2025
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
1147ba3
Runtime: Expose readonly directly off the datastore runtime
anthony-murphy Apr 21, 2025
d69491f
Merge branch 'main' of https://github.com/microsoft/FluidFramework in…
anthony-murphy Apr 21, 2025
a47722c
update type tests
anthony-murphy Apr 21, 2025
f05624c
Merge branch 'main' of https://github.com/microsoft/FluidFramework in…
anthony-murphy Apr 21, 2025
3f54418
revert whitespace
anthony-murphy Apr 21, 2025
6f22dec
update tests
anthony-murphy Apr 22, 2025
780ab0e
fixes
anthony-murphy Apr 22, 2025
b11bf64
regen docs
anthony-murphy Apr 22, 2025
948c6a4
Merge branch 'main' into ro/datastore-readonly
anthony-murphy Apr 22, 2025
413dce5
update feature name
anthony-murphy Apr 22, 2025
5691bb5
Update packages/runtime/container-runtime/src/dataStoreContext.ts
anthony-murphy Apr 22, 2025
0a7fe4d
Update packages/runtime/container-runtime/src/dataStoreContext.ts
anthony-murphy Apr 22, 2025
1f12146
Update packages/runtime/container-runtime/src/dataStoreContext.ts
anthony-murphy Apr 22, 2025
c155032
Update packages/runtime/container-runtime/src/dataStoreContext.ts
anthony-murphy Apr 22, 2025
57a7351
small fixes
anthony-murphy Apr 22, 2025
c8cddcd
Merge branch 'ro/datastore-readonly' of https://github.com/anthony-mu…
anthony-murphy Apr 22, 2025
e465ca4
add some comments
anthony-murphy Apr 22, 2025
e1c1788
Merge branch 'main' of https://github.com/microsoft/FluidFramework in…
anthony-murphy Apr 22, 2025
1e6bead
more comments
anthony-murphy Apr 22, 2025
c5ba247
PR feedback
anthony-murphy Apr 23, 2025
c7ccef3
Merge branch 'main' of https://github.com/microsoft/FluidFramework in…
anthony-murphy Apr 23, 2025
988ab66
update name to notifyReadOnlyState
anthony-murphy Apr 23, 2025
c71914d
fix delta manager proxy disposal
anthony-murphy Apr 23, 2025
58522b6
remove tri-state
anthony-murphy Apr 23, 2025
c27695d
move readonly to method
anthony-murphy Apr 23, 2025
e045be5
fix test
anthony-murphy Apr 23, 2025
880b14e
Update packages/runtime/datastore-definitions/src/dataStoreRuntime.ts
anthony-murphy Apr 23, 2025
7fb62fe
update comments
anthony-murphy Apr 23, 2025
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
8 changes: 4 additions & 4 deletions packages/runtime/container-runtime/src/channelCollection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export function wrapContext(context: IFluidParentContext): IFluidParentContext {
get attachState() {
return context.attachState;
},
get readonly() {
get readonly(): boolean | undefined {
return context.readonly;
},
containerRuntime: context.containerRuntime,
Expand Down Expand Up @@ -1120,12 +1120,12 @@ export class ChannelCollection implements IFluidDataStoreChannel, IDisposable {
}

/**
* Enumerates the contexts and calls setReadOnlyState on them.
* Enumerates the contexts and calls notifyReadOnlyState on them.
*/
public setReadOnlyState(readonly: boolean): void {
public notifyReadOnlyState(readonly: boolean): void {
for (const [fluidDataStoreId, context] of this.contexts) {
try {
context.setReadOnlyState(readonly);
context.notifyReadOnlyState(readonly);
} catch (error) {
this.mc.logger.sendErrorEvent(
{
Expand Down
6 changes: 3 additions & 3 deletions packages/runtime/container-runtime/src/containerRuntime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1723,7 +1723,7 @@ export class ContainerRuntime
new Map<string, string>(dataStoreAliasMap),
async (runtime: ChannelCollection) => provideEntryPoint,
);
this._deltaManager.on("readonly", (readonly) => this.setReadOnlyState(readonly));
this._deltaManager.on("readonly", (readonly) => this.notifyReadOnlyState(readonly));

this.blobManager = new BlobManager({
routeContext: this.handleContext,
Expand Down Expand Up @@ -2565,8 +2565,8 @@ export class ContainerRuntime
return this._loadIdCompressor;
}

public setReadOnlyState(readonly: boolean): void {
this.channelCollection.setReadOnlyState(readonly);
public notifyReadOnlyState(readonly: boolean): void {
this.channelCollection.notifyReadOnlyState(readonly);
}

public setConnectionState(connected: boolean, clientId?: string): void {
Expand Down
6 changes: 3 additions & 3 deletions packages/runtime/container-runtime/src/dataStoreContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -686,10 +686,10 @@ export abstract class FluidDataStoreContext
this.channel!.setConnectionState(connected, clientId);
}

public setReadOnlyState(readonly: boolean): void {
this.verifyNotClosed("setReadOnlyState", false /* checkTombstone */);
public notifyReadOnlyState(readonly: boolean): void {
this.verifyNotClosed("notifyReadOnlyState", false /* checkTombstone */);

this.channel?.setReadOnlyState?.(readonly);
this.channel?.notifyReadOnlyState?.(readonly);
this._contextDeltaManagerProxy.setReadonly(readonly);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
import type { ICriticalContainerError } from "@fluidframework/container-definitions";
import {
encodeHandlesInContainerRuntime,
setReadOnlyState,
notifiesReadOnlyState,
} from "@fluidframework/runtime-definitions/internal";
import { UsageError } from "@fluidframework/telemetry-utils/internal";

Expand Down Expand Up @@ -69,7 +69,7 @@ export const runtimeCompatDetailsForDataStore: ILayerCompatDetails = {
/**
* The features supported by the Runtime layer across the Runtime / DataStore boundary.
*/
supportedFeatures: new Set<string>([encodeHandlesInContainerRuntime, setReadOnlyState]),
supportedFeatures: new Set<string>([encodeHandlesInContainerRuntime, notifiesReadOnlyState]),
};

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export class FluidDataStoreRuntime extends TypedEventEmitter<IFluidDataStoreRunt
// (undocumented)
get logger(): ITelemetryLoggerExt;
makeVisibleAndAttachGraph(): void;
notifyReadOnlyState(readonly: boolean): void;
// (undocumented)
get objectsRoutingContext(): this;
// (undocumented)
Expand All @@ -90,7 +91,6 @@ export class FluidDataStoreRuntime extends TypedEventEmitter<IFluidDataStoreRunt
setAttachState(attachState: AttachState.Attaching | AttachState.Attached): void;
// (undocumented)
setConnectionState(connected: boolean, clientId?: string): void;
setReadOnlyState(readonly: boolean): void;
// (undocumented)
submitMessage(type: DataStoreMessageType, content: any, localOpMetadata: unknown): void;
submitSignal(type: string, content: unknown, targetClientId?: string): void;
Expand Down
10 changes: 5 additions & 5 deletions packages/runtime/datastore/src/dataStoreRuntime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ import {
IInboundSignalMessage,
type IRuntimeMessageCollection,
type IRuntimeMessagesContent,
setReadOnlyState,
notifiesReadOnlyState,
encodeHandlesInContainerRuntime,
} from "@fluidframework/runtime-definitions/internal";
import {
Expand Down Expand Up @@ -110,7 +110,7 @@ type PickRequired<T extends Record<never, unknown>, K extends keyof T> = Omit<T,

interface IFluidDataStoreContextFeaturesToTypes {
[encodeHandlesInContainerRuntime]: IFluidDataStoreContext; // No difference in typing with this feature
[setReadOnlyState]: PickRequired<IFluidDataStoreContext, "readonly">;
[notifiesReadOnlyState]: PickRequired<IFluidDataStoreContext, "readonly">;
}

function contextSupportsFeature<K extends keyof IFluidDataStoreContextFeaturesToTypes>(
Expand Down Expand Up @@ -290,12 +290,12 @@ export class FluidDataStoreRuntime
dataStoreContext as FluidObject<ILayerCompatDetails>;
validateRuntimeCompatibility(runtimeCompatDetails, this.dispose.bind(this));

if (contextSupportsFeature(dataStoreContext, setReadOnlyState)) {
if (contextSupportsFeature(dataStoreContext, notifiesReadOnlyState)) {
this._readonly = dataStoreContext.readonly;
} else {
this._readonly = this.dataStoreContext.deltaManager.readOnlyInfo.readonly === true;
this.dataStoreContext.deltaManager.on("readonly", (readonly) =>
this.setReadOnlyState(readonly),
this.notifyReadOnlyState(readonly),
);
}

Expand Down Expand Up @@ -692,7 +692,7 @@ export class FluidDataStoreRuntime
* readonly state of this object. It should not be invoked by
* any other callers.
*/
public setReadOnlyState(readonly: boolean) {
public notifyReadOnlyState(readonly: boolean): void {
this.verifyNotClosed();
if (readonly !== this._readonly) {
this._readonly = readonly;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ export interface IFluidDataStoreChannel extends IDisposable {
getAttachSummary(telemetryContext?: ITelemetryContext): ISummaryTreeWithStats;
getGCData(fullGC?: boolean): Promise<IGarbageCollectionData>;
makeVisibleAndAttachGraph(): void;
notifyReadOnlyState?(readonly: boolean): void;
processMessages(messageCollection: IRuntimeMessageCollection): void;
processSignal(message: IInboundSignalMessage, local: boolean): void;
// (undocumented)
Expand All @@ -138,7 +139,6 @@ export interface IFluidDataStoreChannel extends IDisposable {
// (undocumented)
setAttachState(attachState: AttachState.Attaching | AttachState.Attached): void;
setConnectionState(connected: boolean, clientId?: string): any;
setReadOnlyState?(readonly: boolean): void;
summarize(fullTree?: boolean, trackState?: boolean, telemetryContext?: ITelemetryContext): Promise<ISummaryTreeWithStats>;
updateUsedRoutes(usedRoutes: string[]): void;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ export interface IFluidDataStoreChannel extends IDisposable {
/**
* Notifies this object about changes in the readonly state
*/
setReadOnlyState?(readonly: boolean): void;
notifyReadOnlyState?(readonly: boolean): void;

/**
* Ask the DDS to resubmit a message. This could be because we reconnected and this message was not acked.
Expand Down
2 changes: 1 addition & 1 deletion packages/runtime/runtime-definitions/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export type {
} from "./protocol.js";
export {
encodeHandlesInContainerRuntime,
setReadOnlyState,
notifiesReadOnlyState,
} from "./runtimeLayerCompatFeatureNames.js";
export type {
CreateChildSummarizerNodeParam,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
export const encodeHandlesInContainerRuntime = "encodeHandlesInContainerRuntime" as const;

/**
* This feature indicates that the datastore context will call setReadOnlyState on the
* This feature indicates that the datastore context will call notifyReadOnlyState on the
* datastore runtime.
* @internal
*/
export const setReadOnlyState = "setReadOnlyState" as const;
export const notifiesReadOnlyState = "notifiesReadOnlyState" as const;
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,8 @@ export class MockFluidDataStoreRuntime extends EventEmitter implements IFluidDat
// (undocumented)
makeVisibleAndAttachGraph(): void;
// (undocumented)
notifyReadOnlyState(readonly: boolean): void;
// (undocumented)
get objectsRoutingContext(): IFluidHandleContext;
// (undocumented)
options: Record<string | number, any>;
Expand Down Expand Up @@ -490,8 +492,6 @@ export class MockFluidDataStoreRuntime extends EventEmitter implements IFluidDat
// (undocumented)
setConnectionState(connected: boolean, clientId?: string): void;
// (undocumented)
setReadOnlyState(readonly: boolean): void;
// (undocumented)
submitMessage(type: MessageType, content: any): null;
// (undocumented)
submitSignal(type: string, content: any): null;
Expand Down
2 changes: 1 addition & 1 deletion packages/runtime/test-runtime-utils/src/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1040,7 +1040,7 @@ export class MockFluidDataStoreRuntime
return;
}

public setReadOnlyState(readonly: boolean) {
public notifyReadOnlyState(readonly: boolean): void {
this.readonly = readonly;
}

Expand Down
Loading