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

Add connect() and disconnect() to IFluidContainer and FluidContainer #9947

Merged
merged 6 commits into from
Apr 20, 2022
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
4 changes: 4 additions & 0 deletions BREAKING.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,14 @@ There are a few steps you can take to write a good change note and avoid needing

## 0.59 Upcoming changes
- [Remove ICodeLoader interface](#Remove-ICodeLoader-interface)
- [IFluidContainer.connect() and IFluidContainer.disconnect() will be made mandatory in future major release](#ifluidcontainer-connect-and-ifluidcontainer-disconnect-will-be-made-mandatory-in-future-major-release)

### Remove ICodeLoader interface
ICodeLoader interface was deprecated a while ago and will be removed in the next release. Please refer to [replace ICodeLoader with ICodeDetailsLoader interface](#Replace-ICodeLoader-with-ICodeDetailsLoader-interface) for more details.

### IFluidContainer.connect() and IFluidContainer.disconnect() will be made mandatory in future major release
In major release 1.0, the optional functions `IFluidContainer.connect()` and `IFluidContainer.disconnect()` will be made mandatory functions.

## 0.59 Breaking changes
- [Removing Commit from TreeEntry and commits from SnapShotTree](#Removing-Commit-from-TreeEntry-and-commits-from-SnapShotTree)
- [raiseContainerWarning removed from IContainerContext](#raiseContainerWarning-removed-from-IContainerContext)
Expand Down
4 changes: 4 additions & 0 deletions api-report/fluid-static.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,11 @@ export class FluidContainer extends TypedEventEmitter<IFluidContainerEvents> imp
constructor(container: IContainer, rootDataObject: RootDataObject);
attach(): Promise<string>;
get attachState(): AttachState;
connect(): Promise<void>;
get connected(): boolean;
get connectionState(): ConnectionState;
create<T extends IFluidLoadable>(objectClass: LoadableObjectClass<T>): Promise<T>;
disconnect(): Promise<void>;
dispose(): void;
get disposed(): boolean;
get initialObjects(): Record<string, IFluidLoadable>;
Expand All @@ -61,10 +63,12 @@ export interface IConnection {
export interface IFluidContainer extends IEventProvider<IFluidContainerEvents> {
attach(): Promise<string>;
readonly attachState: AttachState;
connect?(): void;
// @deprecated
readonly connected: boolean;
readonly connectionState: ConnectionState;
create<T extends IFluidLoadable>(objectClass: LoadableObjectClass<T>): Promise<T>;
disconnect?(): void;
dispose(): void;
readonly disposed: boolean;
readonly initialObjects: LoadableObjectRecord;
Expand Down
6 changes: 5 additions & 1 deletion packages/framework/fluid-static/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@
},
"typeValidation": {
"version": "0.59.2000",
"broken": {}
"broken": {
"ClassDeclaration_FluidContainer": {
"forwardCompat": false
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@heliocliu, I believe this situation is similar to the one in my last PR here. Thoughts on if this is okay to stay in main, or if this PR should be in next?

Copy link
Contributor

Choose a reason for hiding this comment

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

this should be fine in main (since i don't think there are any runtime object compatibility considerations here)

}
}
}
}
24 changes: 24 additions & 0 deletions packages/framework/fluid-static/src/fluidContainer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,16 @@ export interface IFluidContainer extends IEventProvider<IFluidContainerEvents> {
*/
attach(): Promise<string>;

/**
* Attempts to connect the container to the delta stream and process ops
*/
connect?(): void;

/**
* Disconnects the container from the delta stream and stops processing ops
*/
disconnect?(): void;

/**
* Create a new data object or DDS of the specified type. In order to share the data object or DDS with other
* collaborators and retrieve it later, store its handle in a collection like a SharedDirectory from your
Expand Down Expand Up @@ -213,6 +223,20 @@ export class FluidContainer extends TypedEventEmitter<IFluidContainerEvents> imp
throw new Error("Cannot attach container. Container is not in detached state");
}

/**
* {@inheritDoc IFluidContainer.connect}
*/
public async connect(): Promise<void> {
this.container.connect?.();
}

/**
* {@inheritDoc IFluidContainer.connect}
*/
public async disconnect(): Promise<void> {
this.container.disconnect?.();
}

/**
* {@inheritDoc IFluidContainer.create}
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ declare function get_old_ClassDeclaration_FluidContainer():
declare function use_current_ClassDeclaration_FluidContainer(
use: TypeOnly<current.FluidContainer>);
use_current_ClassDeclaration_FluidContainer(
// @ts-expect-error compatibility expected to be broken
get_old_ClassDeclaration_FluidContainer());

/*
Expand Down