-
Notifications
You must be signed in to change notification settings - Fork 334
Replace language server WebSocket connection with Ydoc #14438
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
base: develop
Are you sure you want to change the base?
Conversation
7356274 to
4371781
Compare
| @@ -0,0 +1,3 @@ | |||
| module org.enso.ydoc.api { | |||
| exports org.enso.ydoc.api; | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- There is no need for a new API module.
- there already is YdocServerApi
- please put the new interfaces there as inner classes of
YdocServerApi.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Possibly you can move
YdocServerApito the neworg.enso.ydoc.apimodule. - but the whole API needs to be co-located
| package org.enso.ydoc.api; | ||
|
|
||
| public class NoOpMessageCallbacks implements MessageCallbacks { | ||
| public static final NoOpMessageCallbacks INSTANCE = new NoOpMessageCallbacks(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Please don't put
NoOpMessagesCallbacksimplementation class into the API - remove it
- if you have to have it, then encapsulate it
- put
public static final MessageCallbacks NO_OPintoMessageCallbacksand make the implementation class package private
JaroslavTulach
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- ideally
HostAccessis configured internally - and both tests and production code just work with the default configuration
- possible trick to achieve that is to crate a proxy around interfaces passed to JavaScript
| return this; | ||
| } | ||
|
|
||
| public Builder hostAccessBuilder(HostAccess.Builder hostAccessBuilder) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Why is this a builder?
- Isn't just
HostAccessinstance good enough?
| public Builder hostAccessBuilder(HostAccess.Builder hostAccessBuilder) { | |
| public Builder hostAccess(HostAccess hostAccessBuilder) { |
- without
WebEnvironment.defaultHostAccessbeing public, one might need a builder - but having both builder and
WebEnvironment.defaultHostAccessseems unnecessary
| WebEnvironment.defaultHostAccess | ||
| // allowImplementations is required to call methods on JS objects from Java, i.e. to | ||
| // call methods on `YjsChannel` object returned from JS | ||
| .allowImplementations(YjsChannel.class) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- allowing implementation of a well known interface is OK
- but opening up
allowAccessto a randomcallbacks.getClass()class is a security flaw - please create a proxy around
callbacksand expose its methods- preferrably via
@HostAccess.Explicit - or via
allowAccess(ProxyMessageCallbacks.getDeclararedMethod(""))but while hardcodingProxyMessageCallbacksclass
- preferrably via
| @@ -0,0 +1,3 @@ | |||
| module org.enso.ydoc.api { | |||
| exports org.enso.ydoc.api; | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Possibly you can move
YdocServerApito the neworg.enso.ydoc.apimodule. - but the whole API needs to be co-located
71e9b86 to
8713e6f
Compare
| override def onMessage(message: Object): Unit = { | ||
| message match { | ||
| case m: String => | ||
| val webMessage = MessageHandler.WebMessage(m) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- @4e6 you mentioned last week that the Java part of this PR was "suprisingly simple"
- the change looks really small
- it took me a while to locate where the essential Java part is
- if this
ServerCallbacksinYdocJsonRpcServeris all that's needed then I agree, yes, it seems surprisingly simple
| for (const item of items) { | ||
| // Only notify handlers if the message is from another sender | ||
| if (item.senderId !== this.senderId) { | ||
| this.notifyHandlers(item.payload) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- As of 8713e6f we are probably dealing with ever growing
Y.Array - somehow we need to find out that the "message has been delivered" to all handlers
- that's kind of hard in a distributed framework
- where handlers can appear and diappear
- one solution would be to add
receiverIdtoitem- deliver the message only when
senderIdmatchesreceiverId - e.g.
if (item.receiverId === this.senderId)` - if there was only one receiver of a message
- then it'd be the receiver's responsibility to remove the
itemfromarray
- deliver the message only when
486cb1d to
c1ee0ea
Compare
Pull Request Description
ydoc-servertalking directly to the engine+ls #14142Important Notes
Checklist
Please ensure that the following checklist has been satisfied before submitting the PR:
Scala,
Java,
TypeScript,
and
Rust
style guides. In case you are using a language not listed above, follow the Rust style guide.
or the Snowflake database integration, a run of the Extra Tests has been scheduled.