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
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ export interface IFluidDataStoreRuntime extends IEventProvider<IFluidDataStoreRu
readonly idCompressor: IIdCompressor | undefined;
// (undocumented)
readonly IFluidHandleContext: IFluidHandleContext;
// (undocumented)
readonly isReadOnly: () => boolean;
// (undocumented)
readonly logger: ITelemetryBaseLogger;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ export interface IFluidDataStoreRuntimeEvents extends IEvent {
(event: "op", listener: (message: ISequencedDocumentMessage) => void);
(event: "signal", listener: (message: IInboundSignalMessage, local: boolean) => void);
(event: "connected", listener: (clientId: string) => void);
/*
* The readonly event is fired when the readonly state of the datastore runtime changes.
* The isReadOnly param will express the new readonly state.
*/
(event: "readonly", listener: (isReadOnly: boolean) => void);
}

Expand Down Expand Up @@ -70,6 +74,10 @@ export interface IFluidDataStoreRuntime

readonly connected: boolean;

/**
* Get the current readonly state.
* @returns true if read-only, otherwise false
*/
readonly isReadOnly: () => boolean;

readonly logger: ITelemetryBaseLogger;
Expand Down
3 changes: 3 additions & 0 deletions packages/runtime/datastore/src/dataStoreRuntime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ export class FluidDataStoreRuntime
return this.dataStoreContext.connected;
}

/**
* {@inheritDoc @fluidframework/datastore-definitions#IFluidDataStoreRuntime.isReadOnly}
*/
public readonly isReadOnly = (): boolean => this._readonly;

public get clientId(): string | undefined {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ export interface IFluidParentContext
readonly clientId: string | undefined;
readonly connected: boolean;
/**
* Indicates if the parent context is readonly. If readonly is true, the consumer of
* Indicates if the parent context is readonly. If isReadOnly is true, the consumer of
* the context should also consider themselves readonly.
*/
readonly isReadOnly?: () => boolean;
Expand Down
14 changes: 7 additions & 7 deletions packages/test/local-server-tests/src/test/readonly.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ class DefaultDataStore {
get DefaultDataStore() {
return this;
}
get readonly() {
return this.runtime.readonly;
isReadOnly() {
return this.runtime.isReadOnly();
}

get handle() {
Expand Down Expand Up @@ -151,15 +151,15 @@ describe("readonly", () => {
"container entrypoint must be DefaultDataStore",
);

assert(entrypoint.DefaultDataStore.readonly === false, "shouldn't be readonly");
assert(entrypoint.DefaultDataStore.isReadOnly() === false, "shouldn't be readonly");
assert(
entrypoint.DefaultDataStore.readonlyEventCount === 0,
"shouldn't be any readonly events",
);

await container.attach(urlResolver.createCreateNewRequest("test"));

assert(entrypoint.DefaultDataStore.readonly === false, "shouldn't be readonly");
assert(entrypoint.DefaultDataStore.isReadOnly() === false, "shouldn't be readonly");
assert(
entrypoint.DefaultDataStore.readonlyEventCount === 0,
"shouldn't be any readonly events",
Expand All @@ -178,7 +178,7 @@ describe("readonly", () => {
"container entrypoint must be DefaultDataStore",
);

assert(entrypoint.DefaultDataStore.readonly === false, "shouldn't be readonly");
assert(entrypoint.DefaultDataStore.isReadOnly() === false, "shouldn't be readonly");
assert(
entrypoint.DefaultDataStore.readonlyEventCount === 0,
"shouldn't be any readonly events",
Expand All @@ -199,7 +199,7 @@ describe("readonly", () => {

loadedContainer.forceReadonly?.(true);

assert(entrypoint.DefaultDataStore.readonly === true, "should be readonly");
assert(entrypoint.DefaultDataStore.isReadOnly() === true, "should be readonly");
assert(
entrypoint.DefaultDataStore.readonlyEventCount === 1,
"should be any readonly events",
Expand All @@ -220,7 +220,7 @@ describe("readonly", () => {
"container entrypoint must be DefaultDataStore",
);

assert(entrypoint.DefaultDataStore.readonly === true, "should be readonly");
assert(entrypoint.DefaultDataStore.isReadOnly() === true, "should be readonly");
assert(
entrypoint.DefaultDataStore.readonlyEventCount === 0,
"shouldn't be any readonly events",
Expand Down
Loading