Skip to content

Commit 440a59d

Browse files
committed
Rename JsonRpcProxyFactory and related types
- Rename `JsonRpcProxyFactory` and related types to `RpcProxyFactory` (Rpc*). The naming scheme was a remainder of the old vscode jsonr-rpc based protocol. By simply using the `Rpc` suffix the class names are less misleading and protocol agnostic. - Keep deprecated declarations of the old `JsonRpc*` namespace. The components are heavily used by adopters so we should maintain this deprecated symbols for a while to enable graceful migration without hard API breaks. Naturally this is open for discussion, but judging from the files I had to touch in the core framework alone I think it's definitely a good idea to give adopters a grace period. Complementary website PR: eclipse-theia/theia-website#422 Fixes #12581 Contributed on behalf of STMicroelectronics
1 parent 53b1987 commit 440a59d

File tree

44 files changed

+188
-151
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+188
-151
lines changed

CHANGELOG.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@
1111
- [repo] with the upgrade to Inversify 6.0, a few initialization methods were adjusted. See also [this migration guide entry](https://github.com/eclipse-theia/theia/blob/master/doc/Migration.md#inversify-60). Additionally, other changes include: [#12425](https://github.com/eclipse-theia/theia/pull/12425)
1212
- The type expected by the `PreferenceProxySchema` symbol has been changed from `PromiseLike<PreferenceSchema>` to `() => PromiseLike<PreferenceSchema>`
1313
- The symbol `OnigasmPromise` has been changed to `OnigasmProvider` and injects a function of type `() => Promise<IOnigLib>`
14-
- The symbol `PreferenceTransactionPrelude` has been changed to `PreferenceTransactionPreludeProvider ` and injects a function of type `() => Promise<unknown>`
14+
- The symbol `PreferenceTransactionPrelude` has been changed to `PreferenceTransactionPreludeProvider` and injects a function of type `() => Promise<unknown>`
15+
- [rpc] Replaced name suffixes classes and types that were still referencing the old rpc protocol. From `JsonRpc*` to `Rpc*`.
16+
- Old classes and types are still available but haven been deprecated and might get removed in future releases [#12588](https://github.com/eclipse-theia/theia/pull/12588)
17+
- e.g. `JsonRpcProxyFactory` is deprecated, use `RpcProxyFactory` instead.
1518

1619
## v1.38.0 - 05/25/2023
1720

examples/api-samples/src/common/updater/sample-updater.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
//
1414
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
1515
// *****************************************************************************
16-
import { JsonRpcServer } from '@theia/core/lib/common/messaging/proxy-factory';
16+
import { RpcServer } from '@theia/core/lib/common/messaging/proxy-factory';
1717

1818
export enum UpdateStatus {
1919
InProgress = 'in-progress',
@@ -23,7 +23,7 @@ export enum UpdateStatus {
2323

2424
export const SampleUpdaterPath = '/services/sample-updater';
2525
export const SampleUpdater = Symbol('SampleUpdater');
26-
export interface SampleUpdater extends JsonRpcServer<SampleUpdaterClient> {
26+
export interface SampleUpdater extends RpcServer<SampleUpdaterClient> {
2727
checkForUpdates(): Promise<{ status: UpdateStatus }>;
2828
onRestartToUpdateRequested(): void;
2929
disconnectClient(client: SampleUpdaterClient): void;

examples/api-samples/src/electron-main/update/sample-updater-main-module.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
// *****************************************************************************
1616

1717
import { ContainerModule } from '@theia/core/shared/inversify';
18-
import { JsonRpcConnectionHandler } from '@theia/core/lib/common/messaging/proxy-factory';
18+
import { RpcConnectionHandler } from '@theia/core/lib/common/messaging/proxy-factory';
1919
import { ElectronMainApplicationContribution } from '@theia/core/lib/electron-main/electron-main-application';
2020
import { ElectronConnectionHandler } from '@theia/core/lib/electron-common/messaging/electron-connection-handler';
2121
import { SampleUpdaterPath, SampleUpdater, SampleUpdaterClient } from '../../common/updater/sample-updater';
@@ -26,7 +26,7 @@ export default new ContainerModule(bind => {
2626
bind(SampleUpdater).toService(SampleUpdaterImpl);
2727
bind(ElectronMainApplicationContribution).toService(SampleUpdater);
2828
bind(ElectronConnectionHandler).toDynamicValue(context =>
29-
new JsonRpcConnectionHandler<SampleUpdaterClient>(SampleUpdaterPath, client => {
29+
new RpcConnectionHandler<SampleUpdaterClient>(SampleUpdaterPath, client => {
3030
const server = context.container.get<SampleUpdater>(SampleUpdater);
3131
server.setClient(client);
3232
client.onDidCloseConnection(() => server.disconnectClient(client));

packages/core/src/browser/messaging/ws-connection-provider.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@
1515
// *****************************************************************************
1616

1717
import { injectable, interfaces, decorate, unmanaged } from 'inversify';
18-
import { JsonRpcProxyFactory, JsonRpcProxy, Emitter, Event, Channel } from '../../common';
18+
import { RpcProxyFactory, RpcProxy, Emitter, Event, Channel } from '../../common';
1919
import { Endpoint } from '../endpoint';
2020
import { AbstractConnectionProvider } from '../../common/messaging/abstract-connection-provider';
2121
import { io, Socket } from 'socket.io-client';
2222
import { IWebSocket, WebSocketChannel } from '../../common/messaging/web-socket-channel';
2323

24-
decorate(injectable(), JsonRpcProxyFactory);
25-
decorate(unmanaged(), JsonRpcProxyFactory, 0);
24+
decorate(injectable(), RpcProxyFactory);
25+
decorate(unmanaged(), RpcProxyFactory, 0);
2626

2727
export interface WebSocketOptions {
2828
/**
@@ -44,7 +44,7 @@ export class WebSocketConnectionProvider extends AbstractConnectionProvider<WebS
4444
return this.onSocketDidCloseEmitter.event;
4545
}
4646

47-
static override createProxy<T extends object>(container: interfaces.Container, path: string, arg?: object): JsonRpcProxy<T> {
47+
static override createProxy<T extends object>(container: interfaces.Container, path: string, arg?: object): RpcProxy<T> {
4848
return container.get(WebSocketConnectionProvider).createProxy<T>(path, arg);
4949
}
5050

packages/core/src/common/logger-protocol.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515
// *****************************************************************************
1616

1717
import { injectable } from 'inversify';
18-
import { JsonRpcServer } from './messaging/proxy-factory';
18+
import { RpcServer } from './messaging/proxy-factory';
1919

2020
export const ILoggerServer = Symbol('ILoggerServer');
2121

2222
export const loggerPath = '/services/logger';
2323

24-
export interface ILoggerServer extends JsonRpcServer<ILoggerClient> {
24+
export interface ILoggerServer extends RpcServer<ILoggerClient> {
2525
setLogLevel(name: string, logLevel: number): Promise<void>;
2626
getLogLevel(name: string): Promise<number>;
2727
// eslint-disable-next-line @typescript-eslint/no-explicit-any

packages/core/src/common/messaging/abstract-connection-provider.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import { injectable, interfaces } from 'inversify';
1818
import { Emitter, Event } from '../event';
1919
import { ConnectionHandler } from './handler';
20-
import { JsonRpcProxy, JsonRpcProxyFactory } from './proxy-factory';
20+
import { RpcProxy, RpcProxyFactory } from './proxy-factory';
2121
import { Channel, ChannelMultiplexer } from '../message-rpc/channel';
2222

2323
/**
@@ -32,15 +32,15 @@ export abstract class AbstractConnectionProvider<AbstractOptions extends object>
3232
* Create a proxy object to remote interface of T type
3333
* over an electron ipc connection for the given path and proxy factory.
3434
*/
35-
static createProxy<T extends object>(container: interfaces.Container, path: string, factory: JsonRpcProxyFactory<T>): JsonRpcProxy<T>;
35+
static createProxy<T extends object>(container: interfaces.Container, path: string, factory: RpcProxyFactory<T>): RpcProxy<T>;
3636
/**
3737
* Create a proxy object to remote interface of T type
3838
* over an electron ipc connection for the given path.
3939
*
4040
* An optional target can be provided to handle
4141
* notifications and requests from a remote side.
4242
*/
43-
static createProxy<T extends object>(container: interfaces.Container, path: string, target?: object): JsonRpcProxy<T> {
43+
static createProxy<T extends object>(container: interfaces.Container, path: string, target?: object): RpcProxy<T> {
4444
throw new Error('abstract');
4545
}
4646

@@ -53,17 +53,17 @@ export abstract class AbstractConnectionProvider<AbstractOptions extends object>
5353
* Create a proxy object to remote interface of T type
5454
* over a web socket connection for the given path and proxy factory.
5555
*/
56-
createProxy<T extends object>(path: string, factory: JsonRpcProxyFactory<T>): JsonRpcProxy<T>;
56+
createProxy<T extends object>(path: string, factory: RpcProxyFactory<T>): RpcProxy<T>;
5757
/**
5858
* Create a proxy object to remote interface of T type
5959
* over a web socket connection for the given path.
6060
*
6161
* An optional target can be provided to handle
6262
* notifications and requests from a remote side.
6363
*/
64-
createProxy<T extends object>(path: string, target?: object): JsonRpcProxy<T>;
65-
createProxy<T extends object>(path: string, arg?: object): JsonRpcProxy<T> {
66-
const factory = arg instanceof JsonRpcProxyFactory ? arg : new JsonRpcProxyFactory<T>(arg);
64+
createProxy<T extends object>(path: string, target?: object): RpcProxy<T>;
65+
createProxy<T extends object>(path: string, arg?: object): RpcProxy<T> {
66+
const factory = arg instanceof RpcProxyFactory ? arg : new RpcProxyFactory<T>(arg);
6767
this.listen({
6868
path,
6969
onConnection: c => factory.listen(c)

packages/core/src/common/messaging/proxy-factory.spec.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
// *****************************************************************************
1616

1717
import * as chai from 'chai';
18-
import { JsonRpcProxyFactory, JsonRpcProxy } from './proxy-factory';
18+
import { RpcProxyFactory, RpcProxy } from './proxy-factory';
1919
import { ChannelPipe } from '../message-rpc/channel.spec';
2020

2121
const expect = chai.expect;
@@ -84,19 +84,19 @@ describe('Proxy-Factory', () => {
8484

8585
function getSetup(): {
8686
client: TestClient;
87-
clientProxy: JsonRpcProxy<TestClient>;
87+
clientProxy: RpcProxy<TestClient>;
8888
server: TestServer;
89-
serverProxy: JsonRpcProxy<TestServer>;
89+
serverProxy: RpcProxy<TestServer>;
9090
} {
9191
const client = new TestClient();
9292
const server = new TestServer();
9393

94-
const serverProxyFactory = new JsonRpcProxyFactory<TestServer>(client);
94+
const serverProxyFactory = new RpcProxyFactory<TestServer>(client);
9595
const pipe = new ChannelPipe();
9696
serverProxyFactory.listen(pipe.right);
9797
const serverProxy = serverProxyFactory.createProxy();
9898

99-
const clientProxyFactory = new JsonRpcProxyFactory<TestClient>(server);
99+
const clientProxyFactory = new RpcProxyFactory<TestClient>(server);
100100
clientProxyFactory.listen(pipe.left);
101101
const clientProxy = clientProxyFactory.createProxy();
102102
return {

0 commit comments

Comments
 (0)