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

Deprecate SnapshotConnection.openRemote and make SnapshotConnection.openFile IPC only #7171

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

GytisCepk
Copy link
Contributor

@GytisCepk GytisCepk commented Sep 18, 2024

Public API changes

  • Deprecate SnapshotConnection.openRemote API.
  • Make SnapshotConnection.openFile only available in IPC apps.

Motivation

SnapshotConnection relies on SnapshotIModelRpcInterface for it's communication with the backend. With deprecation and eventual replacement of RPC, all RPC interfaces owned by core need to reviewed and rewritten as needed. While some of the other RPC interfaces (e.g. IModelReadRpcInterface) will need to be converted to the new architecture, I believe, SnapshotIModelRpcInterface can be moved to IPC as it doesn't make sense to have Web implementation for it.

Details

SnapshotConnection / SnapshotIModelRpcInterface has two main methods:

  • openFile(filePath: string, ...) - opening iModel using file path only makes sense if backend is on the same machine. This is the case in Electron and mobile in which IPC can be used. For that reason new IpcApp.appFunctionIpc.openSnapshot was added.
  • openRemote(key: string, ...) - as far as I can tell, this was intended to be used in Web Viewer. Web Viewer and other iTwin.js web applications should be using CheckpointConnection.openRemote(...). Since GPB doesn't have implementation registered for SnapshotIModelRpcInterface, this is not even usable in the web without custom backend.

TODO

  • Confirm if this is a breaking change or not.
  • Find a way to replace SnapshotConnection.openFile in full-stack-tests/core as we will want to keep running those tests in Chrome.
  • Find a way to replace SnapshotConnection.openFile in full-stack-tests/presentation or support IPC there.
  • Don't break display-test-app (usage).
  • Update NextVersion.md.
  • Review and update documentation.

@pmconne
Copy link
Member

pmconne commented Sep 18, 2024

Please add to your TODO list: Don't break display-test-app. See usage here.

@RpcOperation.setRoutingProps(unknownIModelId)
public async openFile(_filePath: string, _opts?: SnapshotOpenOptions): Promise<IModelConnectionProps> { return this.forward(arguments); }

/**
* @deprecated in 4.10. Use [[ConnectionConnection.openRemote]].
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you mean CheckpointConnection?

@@ -487,7 +487,7 @@ export class IModelHost {
[
IModelReadRpcImpl,
IModelTileRpcImpl,
SnapshotIModelRpcImpl,
SnapshotIModelRpcImpl, // eslint-disable-line deprecation/deprecation
WipRpcImpl,
Copy link
Member

Choose a reason for hiding this comment

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

Didnt realize we actually used this WipRpc...
not in this PR's context but we should review its usage and look at killing it off

Copy link
Contributor Author

Choose a reason for hiding this comment

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

WipRpcInterface has no usage in core and shouldn't be used outside core as it's internal.

@@ -224,6 +224,15 @@ class IpcAppHandler extends IpcHandler implements IpcAppFunctions {
public async openStandalone(filePath: string, openMode: OpenMode, opts?: StandaloneOpenOptions): Promise<IModelConnectionProps> {
return StandaloneDb.openFile(filePath, openMode, opts).getConnectionProps();
}
public async openSnapshot(filePath: string, opts?: SnapshotOpenOptions | undefined): Promise<IModelConnectionProps> {
let resolvedFileName: string | undefined = filePath;
if (IModelHost.snapshotFileNameResolver) {
Copy link
Member

Choose a reason for hiding this comment

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

i dont think anyone is actually using this fileNameResolver, id like to try and not carry fwd junk with us

Copy link
Contributor Author

Choose a reason for hiding this comment

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

IModelHost.snapshotFileNameResolver is public and, if we start ignoring it, it would be a breaking change.

We could deprecate it now and stop using it in 5.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants