Skip to content
This repository has been archived by the owner on Apr 4, 2023. It is now read-only.

Move theia remote extension there and align it with new theia 0.3.19 #42

Merged
merged 4 commits into from
Feb 6, 2019

Conversation

benoitf
Copy link
Contributor

@benoitf benoitf commented Jan 30, 2019

this.endpoints = endpointKeys.map(key => process.env[key] || '');
this.logger.info('Plugins Endpoints are ', this.endpoints);

const pluginEndpointKeys: string[] = Object.keys(process.env).filter(key => key.startsWith(HostedPluginMapping.ENDPOINT_ENV_VAR_PREFIX));
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do you need to grab end points second time here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good catch (again)
I think it was a bad refactoring at some time
code was like that in current version
https://github.com/ws-skeleton/che-theia-remote-extension/blob/master/src/node/hosted-plugin-remote.ts#L52-L60

will update, thx

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@akurinnoy ok now ?

* @author Florent Benoit
*/
@injectable()
export class HostedPluginMapping {
Copy link
Contributor

Choose a reason for hiding this comment

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

To me this name is very confusing. AFAIK we call hosted an instance of Theia which hosts plug-in under development. But here we are talking about remote plug-ins which has nothing in common with a plug-in development process. To me RemotePluginMapping works fine. Or maybe I misunderstood something?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's part of the instance of theia which hosts plug-in: pluginHost is the name of what is used to host a plugin ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Then every instance of Theia is hosted, because it has plugins.

Copy link
Contributor

Choose a reason for hiding this comment

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

But I see what you wanted to say. Thanks for explanation.

setupWebsocket(): void {
this.hostedPluginMapping.getEndPoints().forEach(endpointAdress => {
if (endpointAdress) {
const websocket = new ws(endpointAdress);
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor remark: new ws(...) looks strange a bit in terms of naming conventions. WebSocket ?
The same with new Map<string, ws>();. At first glance I thought it is a variabale, not a type...

Copy link
Contributor Author

@benoitf benoitf Feb 1, 2019

Choose a reason for hiding this comment

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

we do

import * as ws from 'ws';

so you want to change the name of the module ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Well, I think it will be better in this particular case (it is local name anyway).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

* @author Florent Benoit
*/
@injectable()
export class HostedPluginRemote {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it for hosted plugin only?

console.log(`Theia Endpoint ${process.pid}/pid listening on port`, PLUGIN_PORT);
const webSocketServer = new WebSocketServerImpl({ port: PLUGIN_PORT });

interface CheckAliveWS extends ws {
Copy link
Contributor

@mmorhun mmorhun Feb 1, 2019

Choose a reason for hiding this comment

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

Please group declaration and commands.
Or would be nice to put all the entrypoint commands into separate function.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok will check. For info it was like that already in the other repository.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

moved console.log command at the end of the file

return socket.terminate();
}
socket.alive = false;
socket.ping();
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should retry a few times in case of short network outage.

Copy link
Contributor

@mmorhun mmorhun left a comment

Choose a reason for hiding this comment

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

It is moving of existing code, so if you have time for improvements it would be nice, but for mow we can merge it as is...

…0.3.19 upstream changes

Change-Id: I13d36ee1a69169f4745da88dfbe081f627b233a9
Signed-off-by: Florent Benoit <fbenoit@redhat.com>
…0.3.19 upstream changes

Change-Id: I704a47e1039b4cc5c5c76f8986e1d1471314d4c9
Signed-off-by: Florent Benoit <fbenoit@redhat.com>
…0.3.19 upstream changes

Change-Id: I9e30a913d403eaf64761d90815c84199ad60372d
Signed-off-by: Florent Benoit <fbenoit@redhat.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants