Fix Flatbuffers Issues for IDE (#741)

This commit is contained in:
Łukasz Olczak 2020-05-13 14:21:33 +02:00 committed by GitHub
parent ed7c2361c2
commit 7d82b1abee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
77 changed files with 579 additions and 454 deletions

View File

@ -73,7 +73,7 @@ services components, as well as any open questions that may remain.
- [`WorkspaceEdit`](#workspaceedit)
- [Connection Management](#connection-management)
- [`session/initProtocolConnection`](#sessioninitprotocolconnection)
- [`session/initDataConnection`](#sessioninitdataconnection)
- [`session/initBinaryConnection`](#sessioninitbinaryconnection)
- [Capability Management](#capability-management)
- [`capability/acquire`](#capabilityacquire)
- [`capability/release`](#capabilityrelease)
@ -87,6 +87,8 @@ services components, as well as any open questions that may remain.
- [File Management Operations](#file-management-operations)
- [`file/write`](#filewrite)
- [`file/read`](#fileread)
- [`file/writeBinary`](#filewritebinary)
- [`file/readBinary`](#filereadbinary)
- [`file/create`](#filecreate)
- [`file/delete`](#filedelete)
- [`file/copy`](#filecopy)
@ -592,21 +594,23 @@ requests, each request/response/notification is wrapped in an envelope
structure. There is a separate envelope for incoming and outgoing messages:
```idl
namespace org.enso.languageserver.protocol.data.envelope;
namespace org.enso.languageserver.protocol.binary;
//A mapping between payload enum and inbound payload types.
union InboundPayload {
SESSION_INIT: org.enso.languageserver.protocol.data.session.SessionInit
INIT_SESSION_CMD: InitSessionCommand,
WRITE_FILE_CMD: WriteFileCommand,
READ_FILE_CMD: ReadFileCommand
}
//An envelope for inbound requests and commands.
table InboundMessage {
//A unique id of the request sent to the server.
requestId: org.enso.languageserver.protocol.data.util.EnsoUUID (required);
//A unique id of the message sent to the server.
messageId: EnsoUUID (required);
//An optional correlation id used to correlate a response with a request.
correlationId: org.enso.languageserver.protocol.data.util.EnsoUUID;
correlationId: EnsoUUID;
//A message payload that carries requests sent by a client.
payload: InboundPayload (required);
@ -615,21 +619,24 @@ table InboundMessage {
```
```idl
namespace org.enso.languageserver.protocol.binary;
//A mapping between payload enum and outbound payload types.
union OutboundPayload {
ERROR: org.enso.languageserver.protocol.data.util.Error,
SESSION_INIT_RESPONSE: org.enso.languageserver.protocol.data.session.SessionInitResponse,
VISUALISATION_UPDATE: org.enso.languageserver.protocol.data.executioncontext.VisualisationUpdate
ERROR: Error,
SUCCESS: Success,
VISUALISATION_UPDATE: VisualisationUpdate,
FILE_CONTENTS_REPLY: FileContentsReply
}
//An envelope for outbound responses.
table OutboundMessage {
//A unique id of the request sent to the server.
requestId: org.enso.languageserver.protocol.data.util.EnsoUUID (required);
//A unique id of the message sent from the server.
messageId: EnsoUUID (required);
//An optional correlation id used to correlate a response with a request.
correlationId: org.enso.languageserver.protocol.data.util.EnsoUUID;
correlationId: EnsoUUID;
//A message payload that carries responses and notifications sent by a server
payload: OutboundPayload (required);
@ -638,9 +645,9 @@ table OutboundMessage {
```
```idl
namespace org.enso.languageserver.protocol.data.util;
namespace org.enso.languageserver.protocol.binary;
//A generic error object.
//This message type is used to indicate failure of some operation performed.
table Error {
//A unique error code identifying error type.
@ -650,6 +657,9 @@ table Error {
message: string;
}
//Indicates an operation has succeeded.
table Success {}
```
### Binary Protocol Communication Patterns
@ -770,6 +780,21 @@ interface Path {
}
```
```idl
namespace org.enso.languageserver.protocol.binary;
//A representation of a path relative to a specified content root.
table Path {
//a content root id that the path is relative to
rootId: EnsoUUID;
//path segments
segments: [string];
}
```
#### `IPWithSocket`
A IPWithSocket is an endpoint for communication between machines.
@ -788,11 +813,17 @@ An EnsoUUID is a value object containing 128-bit universally unique identifier.
##### Format
```idl
namespace org.enso.languageserver.protocol.data.util;
namespace org.enso.languageserver.protocol.binary;
//A binary representation of universally unique identifiers.
struct EnsoUUID {
//The most significant bits of the UUID.
leastSigBits:uint64;
//The most significant bits of the UUID.
mostSigBits:uint64;
}
```
@ -850,8 +881,8 @@ interface ProjectOpenRequest {
```typescript
interface ProjectOpenResult {
languageServerRpcAddress: IPWithSocket;
languageServerDataAddress: IPWithSocket;
languageServerJsonAddress: IPWithSocket;
languageServerBinaryAddress: IPWithSocket;
}
```
@ -1321,7 +1352,7 @@ be correlated between the textual and data connections.
- [`SessionAlreadyInitialisedError`](#sessionalreadyinitialisederror) to signal
that session is already initialised.
#### `session/initDataConnection`
#### `session/initBinaryConnection`
This message initialises the data connection used for transferring binary data
between engine and clients. This initialisation is important such that the
client identifier can be correlated between the data and textual connections.
@ -1334,29 +1365,26 @@ client identifier can be correlated between the data and textual connections.
##### Parameters
```idl
namespace org.enso.languageserver.protocol.data.session;
namespace org.enso.languageserver.protocol.binary;
//A command initializing a data session.
table SessionInit {
table InitSessionCommand {
//A unique identifier of a client initializing the session.
identifier: org.enso.languageserver.protocol.data.util.EnsoUUID (required);
identifier: EnsoUUID (required);
}
//A void response signaling that the session has been initialized.
table SessionInitResponse {}
root_type SessionInit;
root_type SessionInitResponse;
root_type InitSessionCommand;
```
##### Result
```
namespace session;
namespace org.enso.languageserver.protocol.binary;
table InitResponse {}
//Indicates an operation has succeeded.
table Success {}
```
##### Errors
@ -1619,6 +1647,106 @@ return the contents from the in-memory buffer rather than the file on disk.
access to a resource.
- [`FileNotFound`](#filenotfound) informs that file cannot be found.
#### `file/writeBinary`
This requests that the file manager component write to a specified file with
the binary contents.
- **Type:** Request
- **Connection:** Binary
- **Direction:** Client -> Server
This request is _explicitly_ allowed to write to files that do not exist, and
will create them under such circumstances. If a file is recorded as 'open' by
one of the clients, and another client attempts to write to that file, the
write must fail.
##### Parameters
```idl
namespace org.enso.languageserver.protocol.binary;
//A command writing binary contents to a file.
table WriteFileCommand {
//A path to a file.
path: Path;
//Binary contents.
contents: [ubyte];
}
```
##### Result
```idl
namespace org.enso.languageserver.protocol.binary;
//Indicates an operation has succeeded.
table Success {}
```
##### Errors
- [`FileSystemError`](#filesystemerror) to signal a generic, unrecoverable
file-system error.
- [`ContentRootNotFoundError`](#contentrootnotfounderror) to signal that the
requested content root cannot be found.
- [`AccessDeniedError`](#accessdeniederror) to signal that a user doesn't have
access to a resource.
#### `file/readBinary`
This requests that the file manager component reads the binary contents of a
specified file.
- **Type:** Request
- **Direction:** Client -> Server
- **Connection:** Binary
- **Visibility:** Public
If the file is recorded as open by the language server, then the result will
return the contents from the in-memory buffer rather than the file on disk.
##### Parameters
```idl
namespace org.enso.languageserver.protocol.binary;
//A command reading binary contents from a file.
table ReadFileCommand {
//A path to a file.
path: Path;
}
```
##### Result
```idl
namespace org.enso.languageserver.protocol.binary;
//A reply for a ReadFileCommand.
table FileContentsReply {
//Binary contents.
contents: [ubyte];
}
```
##### Errors
- [`FileSystemError`](#filesystemerror) to signal a generic, unrecoverable
file-system error.
- [`ContentRootNotFoundError`](#contentrootnotfounderror) to signal that the
requested content root cannot be found.
- [`AccessDeniedError`](#accessdeniederror) to signal that a user doesn't have
access to a resource.
- [`FileNotFound`](#filenotfound) informs that file cannot be found.
#### `file/create`
This request asks the file manager to create the specified file system object.
@ -2879,19 +3007,19 @@ transport is concerned, it is just a binary blob.
##### Parameters
```idl
namespace org.enso.languageserver.protocol.data.executioncontext;
namespace org.enso.languageserver.protocol.binary;
//A visualisation context identifying a concrete visualisation.
table VisualisationContext {
//A visualisation identifier.
visualisationId: org.enso.languageserver.protocol.data.util.EnsoUUID (required);
visualisationId: EnsoUUID (required);
//A context identifier.
contextId: org.enso.languageserver.protocol.data.util.EnsoUUID (required);
contextId: EnsoUUID (required);
//An expression identifier.
expressionId: org.enso.languageserver.protocol.data.util.EnsoUUID (required);
expressionId: EnsoUUID (required);
}

View File

@ -30,11 +30,11 @@ class LanguageServerComponent(config: LanguageServerConfig)
override def start(): Future[ComponentStarted.type] = {
logger.info("Starting Language Server...")
for {
module <- Future { new MainModule(config) }
rpcBinding <- module.jsonRpcServer.bind(config.interface, config.rpcPort)
dataBinding <- module.dataServer.bind(config.interface, config.dataPort)
module <- Future { new MainModule(config) }
jsonBinding <- module.jsonRpcServer.bind(config.interface, config.rpcPort)
binaryBinding <- module.dataServer.bind(config.interface, config.dataPort)
_ <- Future {
maybeServerCtx = Some(ServerContext(module, rpcBinding, dataBinding))
maybeServerCtx = Some(ServerContext(module, jsonBinding, binaryBinding))
}
_ <- Future {
logger.info(
@ -53,8 +53,8 @@ class LanguageServerComponent(config: LanguageServerConfig)
case Some(serverState) =>
for {
_ <- serverState.rpcBinding.terminate(10.seconds)
_ <- serverState.dataBinding.terminate(10.seconds)
_ <- serverState.jsonBinding.terminate(10.seconds)
_ <- serverState.binaryBinding.terminate(10.seconds)
_ <- serverState.mainModule.system.terminate()
_ <- Future { serverState.mainModule.context.close(true) }
_ <- Future { maybeServerCtx = None }
@ -75,8 +75,8 @@ class LanguageServerComponent(config: LanguageServerConfig)
case Some(serverState) =>
for {
_ <- serverState.rpcBinding.terminate(10.seconds).recover(logError)
_ <- serverState.dataBinding.terminate(10.seconds).recover(logError)
_ <- serverState.jsonBinding.terminate(10.seconds).recover(logError)
_ <- serverState.binaryBinding.terminate(10.seconds).recover(logError)
_ <- serverState.mainModule.system.terminate().recover(logError)
_ <- Future { serverState.mainModule.context.close(true) }
.recover(logError)
@ -97,13 +97,13 @@ object LanguageServerComponent {
* A running server context.
*
* @param mainModule a main module containing all components of the server
* @param rpcBinding a http binding for rpc protocol
* @param dataBinding a http binding for data protocol
* @param jsonBinding a http binding for rpc protocol
* @param binaryBinding a http binding for data protocol
*/
case class ServerContext(
mainModule: MainModule,
rpcBinding: Http.ServerBinding,
dataBinding: Http.ServerBinding
jsonBinding: Http.ServerBinding,
binaryBinding: Http.ServerBinding
)
}

View File

@ -15,13 +15,13 @@ import org.enso.languageserver.filemanager.{
ReceivesTreeUpdatesHandler
}
import org.enso.languageserver.http.server.BinaryWebSocketServer
import org.enso.languageserver.protocol.data.{
import org.enso.languageserver.protocol.binary.{
BinaryConnectionControllerFactory,
InboundMessageDecoder
}
import org.enso.languageserver.protocol.rpc.{
JsonRpc,
RpcConnectionControllerFactory
import org.enso.languageserver.protocol.json.{
JsonConnectionControllerFactory,
JsonRpc
}
import org.enso.languageserver.runtime.{ContextRegistry, RuntimeConnector}
import org.enso.languageserver.session.SessionRouter
@ -120,7 +120,7 @@ class MainModule(serverConfig: LanguageServerConfig) {
.build()
context.initialize(LanguageInfo.ID)
lazy val clientControllerFactory = new RpcConnectionControllerFactory(
lazy val clientControllerFactory = new JsonConnectionControllerFactory(
bufferRegistry,
capabilityRouter,
fileManager,

View File

@ -2,7 +2,7 @@ package org.enso.languageserver.capability
import org.enso.languageserver.data.CapabilityRegistration
import org.enso.languageserver.filemanager.FileSystemFailure
import org.enso.languageserver.session.RpcSession
import org.enso.languageserver.session.JsonSession
object CapabilityProtocol {
@ -13,7 +13,7 @@ object CapabilityProtocol {
* @param registration the capability to grant.
*/
case class AcquireCapability(
rpcSession: RpcSession,
rpcSession: JsonSession,
registration: CapabilityRegistration
)
@ -47,7 +47,7 @@ object CapabilityProtocol {
* @param capability the capability being released.
*/
case class ReleaseCapability(
rpcSession: RpcSession,
rpcSession: JsonSession,
capability: CapabilityRegistration
)

View File

@ -1,6 +1,6 @@
package org.enso.languageserver.event
import org.enso.languageserver.session.{DataSession, RpcSession}
import org.enso.languageserver.session.{BinarySession, JsonSession}
/**
* Base trait for all session events.
@ -12,7 +12,7 @@ sealed trait SessionEvent extends Event
*
* @param session an object representing a client session
*/
case class RpcSessionInitialized(session: RpcSession) extends SessionEvent
case class RpcSessionInitialized(session: JsonSession) extends SessionEvent
/**
* Notifies the Language Server about a client disconnecting rpc session.
@ -20,14 +20,14 @@ case class RpcSessionInitialized(session: RpcSession) extends SessionEvent
*
* @param session an object representing a client session
*/
case class RpcSessionTerminated(session: RpcSession) extends SessionEvent
case class RpcSessionTerminated(session: JsonSession) extends SessionEvent
/**
* Notifies the Language Server about a new data session.
*
* @param session an object representing a client session
*/
case class DataSessionInitialized(session: DataSession) extends SessionEvent
case class DataSessionInitialized(session: BinarySession) extends SessionEvent
/**
* Notifies the Language Server about a client disconnecting data session.
@ -35,4 +35,4 @@ case class DataSessionInitialized(session: DataSession) extends SessionEvent
*
* @param session an object representing a client session
*/
case class DataSessionTerminated(session: DataSession) extends SessionEvent
case class DataSessionTerminated(session: BinarySession) extends SessionEvent

View File

@ -9,7 +9,7 @@ import org.enso.languageserver.filemanager.FileManagerApi.{
OperationTimeoutError
}
import org.enso.jsonrpc.Error
import org.enso.languageserver.protocol.rpc.ErrorApi
import org.enso.languageserver.protocol.json.ErrorApi
object FileSystemFailureMapper {

View File

@ -1,4 +1,4 @@
package org.enso.languageserver.protocol.data
package org.enso.languageserver.protocol.binary
import java.nio.ByteBuffer
import java.util.UUID
@ -15,30 +15,30 @@ import org.enso.languageserver.http.server.BinaryWebSocketControlProtocol.{
ConnectionFailed,
OutboundStreamEstablished
}
import org.enso.languageserver.protocol.data.BinaryConnectionController.InboundPayloadType
import org.enso.languageserver.protocol.data.envelope.InboundPayload.{
import org.enso.languageserver.protocol.binary.InboundPayload.{
INIT_SESSION_CMD,
READ_FILE_CMD,
WRITE_FILE_CMD
}
import org.enso.languageserver.protocol.data.envelope.{
import org.enso.languageserver.protocol.binary.{
EnsoUUID,
InboundMessage,
InitSessionCommand,
OutboundPayload
}
import org.enso.languageserver.protocol.data.factory.{
import org.enso.languageserver.protocol.binary.BinaryConnectionController.InboundPayloadType
import org.enso.languageserver.protocol.binary.factory.{
ErrorFactory,
OutboundMessageFactory,
SuccessReplyFactory,
VisualisationUpdateFactory
}
import org.enso.languageserver.protocol.data.session.InitSessionCommand
import org.enso.languageserver.protocol.data.util.EnsoUUID
import org.enso.languageserver.requesthandler.file.{
ReadBinaryFileHandler,
WriteBinaryFileHandler
}
import org.enso.languageserver.runtime.ContextRegistryProtocol.VisualisationUpdate
import org.enso.languageserver.session.DataSession
import org.enso.languageserver.session.BinarySession
import org.enso.languageserver.util.UnhandledLogging
import org.enso.languageserver.util.binary.DecodingFailure
import org.enso.languageserver.util.binary.DecodingFailure.{
@ -90,9 +90,9 @@ class BinaryConnectionController(
payload.identifier().leastSigBits()
)
val responsePacket = createSessionInitResponsePacket(msg.requestId())
val responsePacket = createSessionInitResponsePacket(msg.messageId())
outboundChannel ! responsePacket
val session = DataSession(clientId, self)
val session = BinarySession(clientId, self)
context.system.eventStream.publish(DataSessionInitialized(session))
log.info(s"Data session initialized for client: $clientId [$clientIp]")
context.become(
@ -128,7 +128,7 @@ class BinaryConnectionController(
}
private def connectionEndHandler(
maybeDataSession: Option[DataSession] = None
maybeDataSession: Option[BinarySession] = None
): Receive = {
case ConnectionClosed =>
log.info(s"Connection closed [$clientIp]")

View File

@ -1,4 +1,4 @@
package org.enso.languageserver.protocol.data
package org.enso.languageserver.protocol.binary
import akka.actor.{ActorRef, ActorSystem, Props}
import akka.http.scaladsl.model.RemoteAddress

View File

@ -1,11 +1,8 @@
package org.enso.languageserver.protocol.data
package org.enso.languageserver.protocol.binary
import java.nio.ByteBuffer
import org.enso.languageserver.protocol.data.envelope.{
InboundMessage,
InboundPayload
}
import org.enso.languageserver.protocol.binary.{InboundMessage, InboundPayload}
import org.enso.languageserver.util.binary.DecodingFailure.{
DataCorrupted,
EmptyPayload,

View File

@ -1,9 +1,9 @@
package org.enso.languageserver.protocol.data.factory
package org.enso.languageserver.protocol.binary.factory
import java.util.UUID
import com.google.flatbuffers.FlatBufferBuilder
import org.enso.languageserver.protocol.data.util.EnsoUUID
import org.enso.languageserver.protocol.binary.EnsoUUID
object EnsoUuidFactory {

View File

@ -1,11 +1,11 @@
package org.enso.languageserver.protocol.data.factory
package org.enso.languageserver.protocol.binary.factory
import java.nio.ByteBuffer
import java.util.UUID
import com.google.flatbuffers.FlatBufferBuilder
import org.enso.languageserver.protocol.data.envelope.OutboundPayload
import org.enso.languageserver.protocol.data.util.{EnsoUUID, Error}
import org.enso.languageserver.protocol.binary.OutboundPayload
import org.enso.languageserver.protocol.binary.{EnsoUUID, Error}
object ErrorFactory {

View File

@ -1,12 +1,12 @@
package org.enso.languageserver.protocol.data.factory
package org.enso.languageserver.protocol.binary.factory
import java.nio.ByteBuffer
import java.util.UUID
import com.google.flatbuffers.FlatBufferBuilder
import org.enso.languageserver.protocol.data.envelope.OutboundPayload
import org.enso.languageserver.protocol.data.filemanager.FileContentsReply
import org.enso.languageserver.protocol.data.util.EnsoUUID
import org.enso.languageserver.protocol.binary.OutboundPayload
import org.enso.languageserver.protocol.binary.FileContentsReply
import org.enso.languageserver.protocol.binary.EnsoUUID
object FileContentsReplyFactory {

View File

@ -1,17 +1,17 @@
package org.enso.languageserver.protocol.data.factory
package org.enso.languageserver.protocol.binary.factory
import java.util.UUID
import com.google.flatbuffers.FlatBufferBuilder
import org.enso.languageserver.protocol.data.envelope.OutboundMessage
import org.enso.languageserver.protocol.data.util.EnsoUUID
import org.enso.languageserver.protocol.binary.OutboundMessage
import org.enso.languageserver.protocol.binary.EnsoUUID
object OutboundMessageFactory {
/**
* Creates an [[OutboundMessage]] inside a [[FlatBufferBuilder]].
*
* @param requestId a unique id of the request sent to the server
* @param messageId a unique id of the message sent from the server
* @param maybeCorrelationId an optional correlation id used to correlate
* a response with a request
* @param payloadType a payload type indicating the type of the payload
@ -23,14 +23,14 @@ object OutboundMessageFactory {
* created object
*/
def create(
requestId: UUID,
messageId: UUID,
maybeCorrelationId: Option[EnsoUUID],
payloadType: Byte,
payload: Int
)(implicit builder: FlatBufferBuilder): Int = {
OutboundMessage.startOutboundMessage(builder)
val reqId = EnsoUuidFactory.create(requestId)
OutboundMessage.addRequestId(builder, reqId)
val reqId = EnsoUuidFactory.create(messageId)
OutboundMessage.addMessageId(builder, reqId)
maybeCorrelationId.foreach { uuid =>
val corId = EnsoUuidFactory.create(uuid)
OutboundMessage.addCorrelationId(builder, corId)

View File

@ -1,11 +1,11 @@
package org.enso.languageserver.protocol.data.factory
package org.enso.languageserver.protocol.binary.factory
import java.nio.ByteBuffer
import java.util.UUID
import com.google.flatbuffers.FlatBufferBuilder
import org.enso.languageserver.protocol.data.envelope.OutboundPayload
import org.enso.languageserver.protocol.data.util.{EnsoUUID, Success}
import org.enso.languageserver.protocol.binary.OutboundPayload
import org.enso.languageserver.protocol.binary.{EnsoUUID, Success}
object SuccessReplyFactory {

View File

@ -1,7 +1,10 @@
package org.enso.languageserver.protocol.data.factory
package org.enso.languageserver.protocol.binary.factory
import com.google.flatbuffers.FlatBufferBuilder
import org.enso.languageserver.protocol.data.executioncontext
import org.enso.languageserver.protocol.binary.{
VisualisationContext => BinaryVisualisationContext,
VisualisationUpdate => BinaryVisualisationUpdate
}
import org.enso.languageserver.runtime.ContextRegistryProtocol.{
VisualisationContext,
VisualisationUpdate
@ -23,9 +26,8 @@ object VisualisationUpdateFactory {
): Int = {
val ctx = createVisualisationCtx(update.visualisationContext)
val data =
executioncontext.VisualisationUpdate
.createDataVector(builder, update.data)
executioncontext.VisualisationUpdate.createVisualisationUpdate(
BinaryVisualisationUpdate.createDataVector(builder, update.data)
BinaryVisualisationUpdate.createVisualisationUpdate(
builder,
ctx,
data
@ -44,14 +46,20 @@ object VisualisationUpdateFactory {
def createVisualisationCtx(ctx: VisualisationContext)(
implicit builder: FlatBufferBuilder
): Int = {
executioncontext.VisualisationContext.startVisualisationContext(builder)
executioncontext.VisualisationContext
.addContextId(builder, EnsoUuidFactory.create(ctx.contextId))
executioncontext.VisualisationContext
.addExpressionId(builder, EnsoUuidFactory.create(ctx.expressionId))
executioncontext.VisualisationContext
.addVisualisationId(builder, EnsoUuidFactory.create(ctx.visualisationId))
executioncontext.VisualisationContext.endVisualisationContext(builder)
BinaryVisualisationContext.startVisualisationContext(builder)
BinaryVisualisationContext.addContextId(
builder,
EnsoUuidFactory.create(ctx.contextId)
)
BinaryVisualisationContext.addExpressionId(
builder,
EnsoUuidFactory.create(ctx.expressionId)
)
BinaryVisualisationContext.addVisualisationId(
builder,
EnsoUuidFactory.create(ctx.visualisationId)
)
BinaryVisualisationContext.endVisualisationContext(builder)
}
}

View File

@ -1,4 +1,4 @@
package org.enso.languageserver.protocol.rpc
package org.enso.languageserver.protocol.json
import org.enso.jsonrpc.Error

View File

@ -1,4 +1,4 @@
package org.enso.languageserver.protocol.rpc
package org.enso.languageserver.protocol.json
import java.util.UUID
@ -36,7 +36,7 @@ import org.enso.languageserver.runtime.VisualisationApi.{
DetachVisualisation,
ModifyVisualisation
}
import org.enso.languageserver.session.RpcSession
import org.enso.languageserver.session.JsonSession
import org.enso.languageserver.session.SessionApi.{
InitProtocolConnection,
SessionAlreadyInitialisedError,
@ -59,7 +59,7 @@ import scala.concurrent.duration._
* @param contextRegistry a router that dispatches execution context requests
* @param requestTimeout a request timeout
*/
class RpcConnectionController(
class JsonConnectionController(
val connectionId: UUID,
val bufferRegistry: ActorRef,
val capabilityRouter: ActorRef,
@ -101,7 +101,7 @@ class RpcConnectionController(
InitProtocolConnection.Params(clientId)
) =>
log.info(s"RPC session initialized for client: $clientId")
val session = RpcSession(clientId, self)
val session = JsonSession(clientId, self)
context.system.eventStream.publish(RpcSessionInitialized(session))
val requestHandlers = createRequestHandlers(session)
val handler = context.actorOf(
@ -119,7 +119,7 @@ class RpcConnectionController(
private def initialised(
webActor: ActorRef,
rpcSession: RpcSession,
rpcSession: JsonSession,
requestHandlers: Map[Method, Props]
): Receive = {
case Request(InitProtocolConnection, id, _) =>
@ -157,7 +157,7 @@ class RpcConnectionController(
}
private def createRequestHandlers(
rpcSession: RpcSession
rpcSession: JsonSession
): Map[Method, Props] =
Map(
Ping -> PingHandler.props(
@ -213,10 +213,10 @@ class RpcConnectionController(
}
object RpcConnectionController {
object JsonConnectionController {
/**
* Creates a configuration object used to create a [[RpcConnectionController]].
* Creates a configuration object used to create a [[JsonConnectionController]].
*
* @param connectionId the internal connection id.
* @param bufferRegistry a router that dispatches text editing requests
@ -235,7 +235,7 @@ object RpcConnectionController {
requestTimeout: FiniteDuration = 10.seconds
): Props =
Props(
new RpcConnectionController(
new JsonConnectionController(
connectionId,
bufferRegistry,
capabilityRouter,

View File

@ -1,4 +1,4 @@
package org.enso.languageserver.protocol.rpc
package org.enso.languageserver.protocol.json
import java.util.UUID
@ -12,7 +12,7 @@ import org.enso.jsonrpc.ClientControllerFactory
* @param capabilityRouter the capability router actor ref
* @param system the actor system
*/
class RpcConnectionControllerFactory(
class JsonConnectionControllerFactory(
bufferRegistry: ActorRef,
capabilityRouter: ActorRef,
fileManager: ActorRef,
@ -28,7 +28,7 @@ class RpcConnectionControllerFactory(
*/
override def createClientController(clientId: UUID): ActorRef =
system.actorOf(
RpcConnectionController.props(
JsonConnectionController.props(
clientId,
bufferRegistry,
capabilityRouter,

View File

@ -1,4 +1,4 @@
package org.enso.languageserver.protocol.rpc
package org.enso.languageserver.protocol.json
import io.circe.generic.auto._
import org.enso.jsonrpc.Protocol

View File

@ -13,7 +13,7 @@ import org.enso.languageserver.capability.CapabilityProtocol.{
import org.enso.languageserver.data.CapabilityRegistration
import org.enso.languageserver.filemanager.FileSystemFailureMapper
import org.enso.languageserver.requesthandler.RequestTimeout
import org.enso.languageserver.session.RpcSession
import org.enso.languageserver.session.JsonSession
import org.enso.languageserver.util.UnhandledLogging
import scala.concurrent.duration.FiniteDuration
@ -28,7 +28,7 @@ import scala.concurrent.duration.FiniteDuration
class AcquireCapabilityHandler(
capabilityRouter: ActorRef,
timeout: FiniteDuration,
session: RpcSession
session: JsonSession
) extends Actor
with ActorLogging
with UnhandledLogging {
@ -91,7 +91,7 @@ object AcquireCapabilityHandler {
def props(
capabilityRouter: ActorRef,
requestTimeout: FiniteDuration,
rpcSession: RpcSession
rpcSession: JsonSession
): Props =
Props(
new AcquireCapabilityHandler(capabilityRouter, requestTimeout, rpcSession)

View File

@ -15,7 +15,7 @@ import org.enso.languageserver.capability.CapabilityProtocol.{
}
import org.enso.languageserver.data.CapabilityRegistration
import org.enso.languageserver.requesthandler.RequestTimeout
import org.enso.languageserver.session.RpcSession
import org.enso.languageserver.session.JsonSession
import org.enso.languageserver.util.UnhandledLogging
import scala.concurrent.duration.FiniteDuration
@ -30,7 +30,7 @@ import scala.concurrent.duration.FiniteDuration
class ReleaseCapabilityHandler(
capabilityRouter: ActorRef,
timeout: FiniteDuration,
session: RpcSession
session: JsonSession
) extends Actor
with ActorLogging
with UnhandledLogging {
@ -86,7 +86,7 @@ object ReleaseCapabilityHandler {
def props(
capabilityRouter: ActorRef,
requestTimeout: FiniteDuration,
rpcSession: RpcSession
rpcSession: JsonSession
): Props =
Props(
new ReleaseCapabilityHandler(capabilityRouter, requestTimeout, rpcSession)

View File

@ -14,7 +14,7 @@ import org.enso.languageserver.runtime.{
ContextRegistryProtocol,
RuntimeFailureMapper
}
import org.enso.languageserver.session.RpcSession
import org.enso.languageserver.session.JsonSession
import org.enso.languageserver.util.UnhandledLogging
import scala.concurrent.duration.FiniteDuration
@ -29,7 +29,7 @@ import scala.concurrent.duration.FiniteDuration
class CreateHandler(
timeout: FiniteDuration,
contextRegistry: ActorRef,
session: RpcSession
session: JsonSession
) extends Actor
with ActorLogging
with UnhandledLogging {
@ -85,7 +85,7 @@ object CreateHandler {
def props(
timeout: FiniteDuration,
contextRegistry: ActorRef,
rpcSession: RpcSession
rpcSession: JsonSession
): Props =
Props(new CreateHandler(timeout, contextRegistry, rpcSession))

View File

@ -9,7 +9,7 @@ import org.enso.languageserver.runtime.{
ContextRegistryProtocol,
RuntimeFailureMapper
}
import org.enso.languageserver.session.RpcSession
import org.enso.languageserver.session.JsonSession
import org.enso.languageserver.util.UnhandledLogging
import scala.concurrent.duration.FiniteDuration
@ -24,7 +24,7 @@ import scala.concurrent.duration.FiniteDuration
class DestroyHandler(
timeout: FiniteDuration,
contextRegistry: ActorRef,
session: RpcSession
session: JsonSession
) extends Actor
with ActorLogging
with UnhandledLogging {
@ -80,7 +80,7 @@ object DestroyHandler {
def props(
timeout: FiniteDuration,
contextRegistry: ActorRef,
rpcSession: RpcSession
rpcSession: JsonSession
): Props =
Props(new DestroyHandler(timeout, contextRegistry, rpcSession))

View File

@ -9,7 +9,7 @@ import org.enso.languageserver.runtime.{
ContextRegistryProtocol,
RuntimeFailureMapper
}
import org.enso.languageserver.session.RpcSession
import org.enso.languageserver.session.JsonSession
import org.enso.languageserver.util.UnhandledLogging
import scala.concurrent.duration.FiniteDuration
@ -24,7 +24,7 @@ import scala.concurrent.duration.FiniteDuration
class PopHandler(
timeout: FiniteDuration,
contextRegistry: ActorRef,
session: RpcSession
session: JsonSession
) extends Actor
with ActorLogging
with UnhandledLogging {
@ -76,7 +76,7 @@ object PopHandler {
def props(
timeout: FiniteDuration,
contextRegistry: ActorRef,
rpcSession: RpcSession
rpcSession: JsonSession
): Props =
Props(new PopHandler(timeout, contextRegistry, rpcSession))

View File

@ -9,7 +9,7 @@ import org.enso.languageserver.runtime.{
ContextRegistryProtocol,
RuntimeFailureMapper
}
import org.enso.languageserver.session.RpcSession
import org.enso.languageserver.session.JsonSession
import org.enso.languageserver.util.UnhandledLogging
import scala.concurrent.duration.FiniteDuration
@ -24,7 +24,7 @@ import scala.concurrent.duration.FiniteDuration
class PushHandler(
timeout: FiniteDuration,
contextRegistry: ActorRef,
session: RpcSession
session: JsonSession
) extends Actor
with ActorLogging
with UnhandledLogging {
@ -84,7 +84,7 @@ object PushHandler {
def props(
timeout: FiniteDuration,
contextRegistry: ActorRef,
rpcSession: RpcSession
rpcSession: JsonSession
): Props =
Props(new PushHandler(timeout, contextRegistry, rpcSession))

View File

@ -9,7 +9,7 @@ import org.enso.languageserver.runtime.{
ContextRegistryProtocol,
RuntimeFailureMapper
}
import org.enso.languageserver.session.RpcSession
import org.enso.languageserver.session.JsonSession
import org.enso.languageserver.util.UnhandledLogging
import scala.concurrent.duration.FiniteDuration
@ -24,7 +24,7 @@ import scala.concurrent.duration.FiniteDuration
class RecomputeHandler(
timeout: FiniteDuration,
contextRegistry: ActorRef,
session: RpcSession
session: JsonSession
) extends Actor
with ActorLogging
with UnhandledLogging {
@ -84,7 +84,7 @@ object RecomputeHandler {
def props(
timeout: FiniteDuration,
contextRegistry: ActorRef,
rpcSession: RpcSession
rpcSession: JsonSession
): Props =
Props(new RecomputeHandler(timeout, contextRegistry, rpcSession))

View File

@ -5,13 +5,15 @@ import org.enso.languageserver.filemanager.{
FileManagerProtocol,
FileSystemFailureMapper
}
import org.enso.languageserver.protocol.data.envelope.InboundMessage
import org.enso.languageserver.protocol.data.factory.{
import org.enso.languageserver.protocol.binary.{
EnsoUUID,
InboundMessage,
ReadFileCommand
}
import org.enso.languageserver.protocol.binary.factory.{
ErrorFactory,
FileContentsReplyFactory
}
import org.enso.languageserver.protocol.data.filemanager.ReadFileCommand
import org.enso.languageserver.protocol.data.util.EnsoUUID
import org.enso.languageserver.requesthandler.RequestTimeout
import org.enso.languageserver.util.UnhandledLogging
import org.enso.languageserver.util.file.PathUtils
@ -45,7 +47,7 @@ class ReadBinaryFileHandler(
fileManager ! FileManagerProtocol.ReadBinaryFile(path)
val cancellable = context.system.scheduler
.scheduleOnce(requestTimeout, self, RequestTimeout)
context.become(responseStage(msg.requestId(), cancellable))
context.become(responseStage(msg.messageId(), cancellable))
}
private def responseStage(

View File

@ -5,13 +5,15 @@ import org.enso.languageserver.filemanager.{
FileManagerProtocol,
FileSystemFailureMapper
}
import org.enso.languageserver.protocol.data.envelope.InboundMessage
import org.enso.languageserver.protocol.data.factory.{
import org.enso.languageserver.protocol.binary.{
EnsoUUID,
InboundMessage,
WriteFileCommand
}
import org.enso.languageserver.protocol.binary.factory.{
ErrorFactory,
SuccessReplyFactory
}
import org.enso.languageserver.protocol.data.filemanager.WriteFileCommand
import org.enso.languageserver.protocol.data.util.EnsoUUID
import org.enso.languageserver.requesthandler.RequestTimeout
import org.enso.languageserver.util.UnhandledLogging
import org.enso.languageserver.util.file.PathUtils
@ -48,7 +50,7 @@ class WriteBinaryFileHandler(
fileManager ! FileManagerProtocol.WriteBinaryFile(path, contents)
val cancellable = context.system.scheduler
.scheduleOnce(requestTimeout, self, RequestTimeout)
context.become(responseStage(msg.requestId(), cancellable))
context.become(responseStage(msg.messageId(), cancellable))
}
private def responseStage(

View File

@ -4,7 +4,7 @@ import akka.actor.{Actor, ActorLogging, ActorRef, Cancellable, Props}
import org.enso.jsonrpc.Errors.ServiceError
import org.enso.jsonrpc._
import org.enso.languageserver.requesthandler.RequestTimeout
import org.enso.languageserver.session.RpcSession
import org.enso.languageserver.session.JsonSession
import org.enso.languageserver.text.TextApi._
import org.enso.languageserver.text.TextProtocol
import org.enso.languageserver.text.TextProtocol.{ApplyEdit => _, _}
@ -22,7 +22,7 @@ import scala.concurrent.duration.FiniteDuration
class ApplyEditHandler(
bufferRegistry: ActorRef,
timeout: FiniteDuration,
rpcSession: RpcSession
rpcSession: JsonSession
) extends Actor
with ActorLogging
with UnhandledLogging {
@ -92,7 +92,7 @@ object ApplyEditHandler {
def props(
bufferRegistry: ActorRef,
requestTimeout: FiniteDuration,
rpcSession: RpcSession
rpcSession: JsonSession
): Props =
Props(new ApplyEditHandler(bufferRegistry, requestTimeout, rpcSession))

View File

@ -4,7 +4,7 @@ import akka.actor.{Actor, ActorLogging, ActorRef, Cancellable, Props}
import org.enso.jsonrpc.Errors.ServiceError
import org.enso.jsonrpc._
import org.enso.languageserver.requesthandler.RequestTimeout
import org.enso.languageserver.session.RpcSession
import org.enso.languageserver.session.JsonSession
import org.enso.languageserver.text.TextApi.{CloseFile, FileNotOpenedError}
import org.enso.languageserver.text.TextProtocol
import org.enso.languageserver.text.TextProtocol.{FileClosed, FileNotOpened}
@ -22,7 +22,7 @@ import scala.concurrent.duration.FiniteDuration
class CloseFileHandler(
bufferRegistry: ActorRef,
timeout: FiniteDuration,
rpcSession: RpcSession
rpcSession: JsonSession
) extends Actor
with ActorLogging
with UnhandledLogging {
@ -74,7 +74,7 @@ object CloseFileHandler {
def props(
bufferRegistry: ActorRef,
requestTimeout: FiniteDuration,
rpcSession: RpcSession
rpcSession: JsonSession
): Props =
Props(new CloseFileHandler(bufferRegistry, requestTimeout, rpcSession))

View File

@ -5,7 +5,7 @@ import org.enso.jsonrpc.Errors.ServiceError
import org.enso.jsonrpc.{Id, Request, ResponseError, ResponseResult}
import org.enso.languageserver.filemanager.FileSystemFailureMapper
import org.enso.languageserver.requesthandler.RequestTimeout
import org.enso.languageserver.session.RpcSession
import org.enso.languageserver.session.JsonSession
import org.enso.languageserver.text.TextApi.OpenFile
import org.enso.languageserver.text.TextProtocol
import org.enso.languageserver.text.TextProtocol.{
@ -26,7 +26,7 @@ import scala.concurrent.duration.FiniteDuration
class OpenFileHandler(
bufferRegistry: ActorRef,
timeout: FiniteDuration,
rpcSession: RpcSession
rpcSession: JsonSession
) extends Actor
with ActorLogging
with UnhandledLogging {
@ -86,7 +86,7 @@ object OpenFileHandler {
def props(
bufferRegistry: ActorRef,
requestTimeout: FiniteDuration,
rpcSession: RpcSession
rpcSession: JsonSession
): Props =
Props(new OpenFileHandler(bufferRegistry, requestTimeout, rpcSession))

View File

@ -5,7 +5,7 @@ import org.enso.jsonrpc.Errors.ServiceError
import org.enso.jsonrpc._
import org.enso.languageserver.filemanager.FileSystemFailureMapper
import org.enso.languageserver.requesthandler.RequestTimeout
import org.enso.languageserver.session.RpcSession
import org.enso.languageserver.session.JsonSession
import org.enso.languageserver.text.TextApi.{
FileNotOpenedError,
InvalidVersionError,
@ -28,7 +28,7 @@ import scala.concurrent.duration.FiniteDuration
class SaveFileHandler(
bufferRegistry: ActorRef,
timeout: FiniteDuration,
rpcSession: RpcSession
rpcSession: JsonSession
) extends Actor
with ActorLogging
with UnhandledLogging {
@ -105,7 +105,7 @@ object SaveFileHandler {
def props(
bufferRegistry: ActorRef,
requestTimeout: FiniteDuration,
rpcSession: RpcSession
rpcSession: JsonSession
): Props =
Props(new SaveFileHandler(bufferRegistry, requestTimeout, rpcSession))

View File

@ -7,8 +7,8 @@ import org.enso.languageserver.runtime.ContextRegistryProtocol.{
VisualisationUpdate
}
import org.enso.languageserver.runtime.ExecutionApi.ContextId
import org.enso.languageserver.session.RpcSession
import org.enso.languageserver.session.SessionRouter.DeliverToDataController
import org.enso.languageserver.session.JsonSession
import org.enso.languageserver.session.SessionRouter.DeliverToBinaryController
import org.enso.languageserver.util.UnhandledLogging
import org.enso.polyglot.runtime.Runtime.Api
@ -24,7 +24,7 @@ import org.enso.polyglot.runtime.Runtime.Api
*/
final class ContextEventsListener(
config: Config,
rpcSession: RpcSession,
rpcSession: JsonSession,
contextId: ContextId,
sessionRouter: ActorRef
) extends Actor
@ -49,7 +49,7 @@ final class ContextEventsListener(
),
data
)
sessionRouter ! DeliverToDataController(rpcSession.clientId, payload)
sessionRouter ! DeliverToBinaryController(rpcSession.clientId, payload)
case Api.ExpressionValuesComputed(`contextId`, apiUpdates) =>
val updates = apiUpdates.flatMap { update =>
@ -121,7 +121,7 @@ object ContextEventsListener {
*/
def props(
config: Config,
rpcSession: RpcSession,
rpcSession: JsonSession,
contextId: ContextId,
sessionRouter: ActorRef
): Props =

View File

@ -5,7 +5,7 @@ import java.util.UUID
import org.enso.languageserver.data.ClientId
import org.enso.languageserver.filemanager.FileSystemFailure
import org.enso.languageserver.runtime.ExecutionApi.ContextId
import org.enso.languageserver.session.RpcSession
import org.enso.languageserver.session.JsonSession
object ContextRegistryProtocol {
@ -19,7 +19,7 @@ object ContextRegistryProtocol {
*
* @param rpcSession reference to the client
*/
case class CreateContextRequest(rpcSession: RpcSession)
case class CreateContextRequest(rpcSession: JsonSession)
/**
* A response about creation of a new execution context.
@ -33,7 +33,10 @@ object ContextRegistryProtocol {
*
* @param rpcSession reference to the client
*/
case class DestroyContextRequest(rpcSession: RpcSession, contextId: ContextId)
case class DestroyContextRequest(
rpcSession: JsonSession,
contextId: ContextId
)
/**
* A response about deletion of an execution context.
@ -51,7 +54,7 @@ object ContextRegistryProtocol {
* @param stackItem an object representing an item on the stack
*/
case class PushContextRequest(
rpcSession: RpcSession,
rpcSession: JsonSession,
contextId: ContextId,
stackItem: StackItem
)
@ -70,7 +73,7 @@ object ContextRegistryProtocol {
* @param rpcSession reference to the client
* @param contextId execution context identifier
*/
case class PopContextRequest(rpcSession: RpcSession, contextId: ContextId)
case class PopContextRequest(rpcSession: JsonSession, contextId: ContextId)
/**
* A response about popping the stack.
@ -87,7 +90,7 @@ object ContextRegistryProtocol {
* @param invalidatedExpressions the expressions that should be invalidated
*/
case class RecomputeContextRequest(
rpcSession: RpcSession,
rpcSession: JsonSession,
contextId: ContextId,
invalidatedExpressions: Option[InvalidatedExpressions]
)

View File

@ -1,7 +1,7 @@
package org.enso.languageserver.runtime
import org.enso.languageserver.filemanager.FileSystemFailureMapper
import org.enso.languageserver.protocol.rpc.ErrorApi._
import org.enso.languageserver.protocol.json.ErrorApi._
import org.enso.languageserver.runtime.ExecutionApi._
import org.enso.polyglot.runtime.Runtime.Api
import org.enso.jsonrpc.Error

View File

@ -11,4 +11,4 @@ import org.enso.languageserver.data.ClientId
* @param dataController the actor handling remote client communications, used
* to push requests and notifications.
*/
case class DataSession(clientId: ClientId, dataController: ActorRef)
case class BinarySession(clientId: ClientId, dataController: ActorRef)

View File

@ -11,7 +11,7 @@ import org.enso.languageserver.data.ClientId
* @param rpcController the actor handling remote client communications, used
* to push requests and notifications.
*/
case class RpcSession(
case class JsonSession(
clientId: ClientId,
rpcController: ActorRef
)

View File

@ -7,26 +7,26 @@ import org.enso.languageserver.data.ClientId
* rpc and data protocol.
*
* @param clientId the internal id of this client
* @param maybeRpcSession a session for rpc protocol
* @param maybeDataSession a session for data protocol
* @param maybeJsonSession a session for rpc protocol
* @param maybeBinarySession a session for data protocol
*/
case class Session(
clientId: ClientId,
maybeRpcSession: Option[RpcSession],
maybeDataSession: Option[DataSession]
maybeJsonSession: Option[JsonSession],
maybeBinarySession: Option[BinarySession]
) {
def attachRpcSession(rpcSession: RpcSession): Session =
this.copy(maybeRpcSession = Some(rpcSession))
def attachJsonSession(rpcSession: JsonSession): Session =
this.copy(maybeJsonSession = Some(rpcSession))
def attachDataSession(dataSession: DataSession): Session =
this.copy(maybeDataSession = Some(dataSession))
def attachBinarySession(dataSession: BinarySession): Session =
this.copy(maybeBinarySession = Some(dataSession))
def detachRpcSession(): Session = this.copy(maybeRpcSession = None)
def detachJsonSession(): Session = this.copy(maybeJsonSession = None)
def detachDataSession(): Session = this.copy(maybeDataSession = None)
def detachBinarySession(): Session = this.copy(maybeBinarySession = None)
def isSessionTerminated: Boolean =
maybeRpcSession.isEmpty && maybeDataSession.isEmpty
maybeJsonSession.isEmpty && maybeBinarySession.isEmpty
}

View File

@ -10,8 +10,8 @@ import org.enso.languageserver.event.{
SessionEvent
}
import org.enso.languageserver.session.SessionRouter.{
DeliverToDataController,
DeliverToRpcController
DeliverToBinaryController,
DeliverToJsonController
}
/**
@ -28,43 +28,43 @@ class SessionRouter extends Actor {
running(Map.empty.withDefault(clientId => Session(clientId, None, None)))
private def running(sessions: Map[ClientId, Session]): Receive = {
case RpcSessionInitialized(s @ RpcSession(clientId, _)) =>
case RpcSessionInitialized(s @ JsonSession(clientId, _)) =>
context.become(
running(
sessions + (clientId -> sessions(clientId).attachRpcSession(s))
sessions + (clientId -> sessions(clientId).attachJsonSession(s))
)
)
case RpcSessionTerminated(RpcSession(clientId, _)) =>
case RpcSessionTerminated(JsonSession(clientId, _)) =>
val updatedSessions =
(sessions + (clientId -> sessions(clientId).detachRpcSession()))
(sessions + (clientId -> sessions(clientId).detachJsonSession()))
.filterNot(_._2.isSessionTerminated)
context.become(running(updatedSessions))
case DataSessionInitialized(s @ DataSession(clientId, _)) =>
case DataSessionInitialized(s @ BinarySession(clientId, _)) =>
context.become(
running(
sessions + (clientId -> sessions(clientId).attachDataSession(s))
sessions + (clientId -> sessions(clientId).attachBinarySession(s))
)
)
case DataSessionTerminated(DataSession(clientId, _)) =>
case DataSessionTerminated(BinarySession(clientId, _)) =>
val updatedSessions =
(sessions + (clientId -> sessions(clientId).detachDataSession()))
(sessions + (clientId -> sessions(clientId).detachBinarySession()))
.filterNot(_._2.isSessionTerminated)
context.become(running(updatedSessions))
case DeliverToRpcController(clientId, payload) =>
case DeliverToJsonController(clientId, payload) =>
sessions
.get(clientId)
.foreach(_.maybeRpcSession.foreach(_.rpcController ! payload))
.foreach(_.maybeJsonSession.foreach(_.rpcController ! payload))
case DeliverToDataController(clientId, payload) =>
case DeliverToBinaryController(clientId, payload) =>
sessions
.get(clientId)
.foreach(_.maybeDataSession.foreach(_.dataController ! payload))
.foreach(_.maybeBinarySession.foreach(_.dataController ! payload))
}
}
@ -79,7 +79,7 @@ object SessionRouter {
* @param payload a payload that is delivered to the controller
* @tparam A a type of payload
*/
case class DeliverToRpcController[A](clientId: ClientId, payload: A)
case class DeliverToJsonController[A](clientId: ClientId, payload: A)
/**
* A command used to deliver an arbitrary `payload` to a data controller
@ -89,7 +89,7 @@ object SessionRouter {
* @param payload a payload that is delivered to the controller
* @tparam A a type of payload
*/
case class DeliverToDataController[A](clientId: ClientId, payload: A)
case class DeliverToBinaryController[A](clientId: ClientId, payload: A)
/**
* Creates configuration object used to create a [[SessionRouter]].

View File

@ -24,7 +24,7 @@ import org.enso.languageserver.filemanager.{
OperationTimeout,
Path
}
import org.enso.languageserver.session.RpcSession
import org.enso.languageserver.session.JsonSession
import org.enso.languageserver.text.Buffer.Version
import org.enso.languageserver.text.CollaborativeBuffer.IOTimeout
import org.enso.languageserver.text.TextProtocol._
@ -74,7 +74,7 @@ class CollaborativeBuffer(
}
private def waitingForFileContent(
rpcSession: RpcSession,
rpcSession: JsonSession,
replyTo: ActorRef,
timeoutCancellable: Cancellable
): Receive = {
@ -97,8 +97,8 @@ class CollaborativeBuffer(
private def collaborativeEditing(
buffer: Buffer,
clients: Map[ClientId, RpcSession],
lockHolder: Option[RpcSession]
clients: Map[ClientId, JsonSession],
lockHolder: Option[JsonSession]
): Receive = {
case OpenFile(client, _) =>
openFile(buffer, clients, lockHolder, client)
@ -131,8 +131,8 @@ class CollaborativeBuffer(
private def saving(
buffer: Buffer,
clients: Map[ClientId, RpcSession],
lockHolder: Option[RpcSession],
clients: Map[ClientId, JsonSession],
lockHolder: Option[JsonSession],
replyTo: ActorRef,
timeoutCancellable: Cancellable
): Receive = {
@ -158,8 +158,8 @@ class CollaborativeBuffer(
private def saveFile(
buffer: Buffer,
clients: Map[ClientId, RpcSession],
lockHolder: Option[RpcSession],
clients: Map[ClientId, JsonSession],
lockHolder: Option[JsonSession],
clientId: ClientId,
clientVersion: Version
): Unit = {
@ -186,8 +186,8 @@ class CollaborativeBuffer(
private def edit(
buffer: Buffer,
clients: Map[ClientId, RpcSession],
lockHolder: Option[RpcSession],
clients: Map[ClientId, JsonSession],
lockHolder: Option[JsonSession],
clientId: ClientId,
change: FileEdit
): Unit = {
@ -210,7 +210,7 @@ class CollaborativeBuffer(
private def applyEdits(
buffer: Buffer,
lockHolder: Option[RpcSession],
lockHolder: Option[JsonSession],
clientId: ClientId,
change: FileEdit
): Either[ApplyEditFailure, Buffer] =
@ -233,7 +233,7 @@ class CollaborativeBuffer(
}
private def validateAccess(
lockHolder: Option[RpcSession],
lockHolder: Option[JsonSession],
clientId: ClientId
): Either[ApplyEditFailure, Unit] = {
val hasLock = lockHolder.exists(_.clientId == clientId)
@ -265,7 +265,7 @@ class CollaborativeBuffer(
TextEditValidationFailed(s"Invalid position: $position")
}
private def readFile(rpcSession: RpcSession, path: Path): Unit = {
private def readFile(rpcSession: JsonSession, path: Path): Unit = {
fileManager ! FileManagerProtocol.ReadFile(path)
val timeoutCancellable = context.system.scheduler
.scheduleOnce(timeout, self, IOTimeout)
@ -275,7 +275,7 @@ class CollaborativeBuffer(
}
private def handleFileContent(
rpcSession: RpcSession,
rpcSession: JsonSession,
originalSender: ActorRef,
file: TextualFileContent
): Unit = {
@ -298,9 +298,9 @@ class CollaborativeBuffer(
private def openFile(
buffer: Buffer,
clients: Map[ClientId, RpcSession],
lockHolder: Option[RpcSession],
rpcSession: RpcSession
clients: Map[ClientId, JsonSession],
lockHolder: Option[JsonSession],
rpcSession: JsonSession
): Unit = {
val writeCapability =
if (lockHolder.isEmpty)
@ -319,8 +319,8 @@ class CollaborativeBuffer(
private def removeClient(
buffer: Buffer,
clients: Map[ClientId, RpcSession],
lockHolder: Option[RpcSession],
clients: Map[ClientId, JsonSession],
lockHolder: Option[JsonSession],
clientId: ClientId
): Unit = {
val newLock =
@ -339,8 +339,8 @@ class CollaborativeBuffer(
private def releaseWriteLock(
buffer: Buffer,
clients: Map[ClientId, RpcSession],
lockHolder: Option[RpcSession],
clients: Map[ClientId, JsonSession],
lockHolder: Option[JsonSession],
clientId: ClientId
): Unit = {
lockHolder match {
@ -360,9 +360,9 @@ class CollaborativeBuffer(
private def acquireWriteLock(
buffer: Buffer,
clients: Map[ClientId, RpcSession],
lockHolder: Option[RpcSession],
clientId: RpcSession,
clients: Map[ClientId, JsonSession],
lockHolder: Option[JsonSession],
clientId: JsonSession,
path: Path
): Unit = {
lockHolder match {

View File

@ -2,7 +2,7 @@ package org.enso.languageserver.text
import org.enso.languageserver.data.{CapabilityRegistration, ClientId}
import org.enso.languageserver.filemanager.{FileSystemFailure, Path}
import org.enso.languageserver.session.RpcSession
import org.enso.languageserver.session.JsonSession
object TextProtocol {
@ -11,7 +11,7 @@ object TextProtocol {
* @param rpcSession the client opening the file.
* @param path the file path.
*/
case class OpenFile(rpcSession: RpcSession, path: Path)
case class OpenFile(rpcSession: JsonSession, path: Path)
/** Sent by the server in response to [[OpenFile]]
*

View File

@ -1,7 +1,7 @@
package org.enso.languageserver.util.file
import org.enso.languageserver.filemanager.Path
import org.enso.languageserver.protocol.data.filemanager.{Path => BinaryPath}
import org.enso.languageserver.protocol.binary.{Path => BinaryPath}
object PathUtils {

View File

@ -2,7 +2,7 @@ package org.enso.languageserver.util.file
import java.util.UUID
import org.enso.languageserver.protocol.data.util.EnsoUUID
import org.enso.languageserver.protocol.binary.EnsoUUID
object UuidUtils {

View File

@ -0,0 +1,144 @@
namespace org.enso.languageserver.protocol.binary;
//A mapping between payload enum and inbound payload types.
union InboundPayload {
INIT_SESSION_CMD: InitSessionCommand,
WRITE_FILE_CMD: WriteFileCommand,
READ_FILE_CMD: ReadFileCommand
}
//An envelope for inbound requests and commands.
table InboundMessage {
//A unique id of the message sent to the server.
messageId: EnsoUUID (required);
//An optional correlation id used to correlate a response with a request.
correlationId: EnsoUUID;
//A message payload that carries requests sent by a client.
payload: InboundPayload (required);
}
//A mapping between payload enum and outbound payload types.
union OutboundPayload {
ERROR: Error,
SUCCESS: Success,
VISUALISATION_UPDATE: VisualisationUpdate,
FILE_CONTENTS_REPLY: FileContentsReply
}
//An envelope for outbound responses.
table OutboundMessage {
//A unique id of the message sent from the server.
messageId: EnsoUUID (required);
//An optional correlation id used to correlate a response with a request.
correlationId: EnsoUUID;
//A message payload that carries responses and notifications sent by a server
payload: OutboundPayload (required);
}
//A binary representation of universally unique identifiers.
struct EnsoUUID {
//The most significant bits of the UUID.
leastSigBits:uint64;
//The most significant bits of the UUID.
mostSigBits:uint64;
}
//This message type is used to indicate failure of some operation performed.
table Error {
//A unique error code identifying error type.
code: int;
//An error message.
message: string;
}
//Indicates an operation has succeeded.
table Success {}
//A command initializing a data session.
table InitSessionCommand {
//A unique identifier of a client initializing the session.
identifier: EnsoUUID (required);
}
root_type InitSessionCommand;
//A visualisation context identifying a concrete visualisation.
table VisualisationContext {
//A visualisation identifier.
visualisationId: EnsoUUID (required);
//A context identifier.
contextId: EnsoUUID (required);
//An expression identifier.
expressionId: EnsoUUID (required);
}
//An event signaling visualisation update.
table VisualisationUpdate {
//A visualisation context identifying a concrete visualisation.
visualisationContext: VisualisationContext (required);
//A visualisation data.
data: [ubyte] (required);
}
//A representation of a path relative to a specified content root.
table Path {
//a content root id that the path is relative to
rootId: EnsoUUID;
//path segments
segments: [string];
}
//A command writing binary contents to a file.
table WriteFileCommand {
//A path to a file.
path: Path;
//Binary contents.
contents: [ubyte];
}
//A command reading binary contents from a file.
table ReadFileCommand {
//A path to a file.
path: Path;
}
//A reply for a ReadFileCommand.
table FileContentsReply {
//Binary contents.
contents: [ubyte];
}
//todo Split up the schema once Rust bugs will be resolved.

View File

@ -1,49 +0,0 @@
include "util.fbs";
include "session.fbs";
include "execution_context.fbs";
include "file_manager.fbs";
namespace org.enso.languageserver.protocol.data.envelope;
//A mapping between payload enum and inbound payload types.
union InboundPayload {
INIT_SESSION_CMD: org.enso.languageserver.protocol.data.session.InitSessionCommand,
WRITE_FILE_CMD: org.enso.languageserver.protocol.data.filemanager.WriteFileCommand,
READ_FILE_CMD: org.enso.languageserver.protocol.data.filemanager.ReadFileCommand
}
//An envelope for inbound requests and commands.
table InboundMessage {
//A unique id of the request sent to the server.
requestId: org.enso.languageserver.protocol.data.util.EnsoUUID (required);
//An optional correlation id used to correlate a response with a request.
correlationId: org.enso.languageserver.protocol.data.util.EnsoUUID;
//A message payload that carries requests sent by a client.
payload: InboundPayload (required);
}
//A mapping between payload enum and outbound payload types.
union OutboundPayload {
ERROR: org.enso.languageserver.protocol.data.util.Error,
SUCCESS: org.enso.languageserver.protocol.data.util.Success,
VISUALISATION_UPDATE: org.enso.languageserver.protocol.data.executioncontext.VisualisationUpdate,
FILE_CONTENTS_REPLY: org.enso.languageserver.protocol.data.filemanager.FileContentsReply
}
//An envelope for outbound responses.
table OutboundMessage {
//A unique id of the request sent to the server.
requestId: org.enso.languageserver.protocol.data.util.EnsoUUID (required);
//An optional correlation id used to correlate a response with a request.
correlationId: org.enso.languageserver.protocol.data.util.EnsoUUID;
//A message payload that carries responses and notifications sent by a server
payload: OutboundPayload (required);
}

View File

@ -1,28 +0,0 @@
include "util.fbs";
namespace org.enso.languageserver.protocol.data.executioncontext;
//A visualisation context identifying a concrete visualisation.
table VisualisationContext {
//A visualisation identifier.
visualisationId: org.enso.languageserver.protocol.data.util.EnsoUUID (required);
//A context identifier.
contextId: org.enso.languageserver.protocol.data.util.EnsoUUID (required);
//An expression identifier.
expressionId: org.enso.languageserver.protocol.data.util.EnsoUUID (required);
}
//An event signaling visualisation update.
table VisualisationUpdate {
//A visualisation context identifying a concrete visualisation.
visualisationContext: VisualisationContext (required);
//A visualisation data.
data: [ubyte] (required);
}

View File

@ -1,41 +0,0 @@
include "util.fbs";
namespace org.enso.languageserver.protocol.data.filemanager;
//A representation of a path relative to a specified content root.
table Path {
//a content root id that the path is relative to
rootId: org.enso.languageserver.protocol.data.util.EnsoUUID;
//path segments
segments: [string];
}
//A command writing binary contents to a file.
table WriteFileCommand {
//A path to a file.
path: org.enso.languageserver.protocol.data.filemanager.Path;
//Binary contents.
contents: [ubyte];
}
//A command reading binary contents from a file.
table ReadFileCommand {
//A path to a file.
path: org.enso.languageserver.protocol.data.filemanager.Path;
}
//A reply for a ReadFileCommand.
table FileContentsReply {
//Binary contents.
contents: [ubyte];
}

View File

@ -1,13 +0,0 @@
include "util.fbs";
namespace org.enso.languageserver.protocol.data.session;
//A command initializing a data session.
table InitSessionCommand {
//A unique identifier of a client initializing the session.
identifier: org.enso.languageserver.protocol.data.util.EnsoUUID (required);
}
root_type InitSessionCommand;

View File

@ -1,26 +0,0 @@
namespace org.enso.languageserver.protocol.data.util;
//A binary representation of universally unique identifiers.
struct EnsoUUID {
//The most significant bits of the UUID.
leastSigBits:uint64;
//The most significant bits of the UUID.
mostSigBits:uint64;
}
//This message type is used to indicate failure of some operation performed.
table Error {
//A unique error code identifying error type.
code: int;
//An error message.
message: string;
}
//Indicates an operation has succeeded.
table Success {}

View File

@ -4,7 +4,7 @@
<!-- encoders are assigned the type
ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%-15thread] %-5level %msg%n</pattern>
<pattern>%d{HH:mm:ss.SSS} [%-15thread] %-5level %logger{36} %msg%n</pattern>
</encoder>
</appender>

View File

@ -1,4 +1,4 @@
package org.enso.languageserver.websocket.data
package org.enso.languageserver.websocket.binary
import java.nio.ByteBuffer
import java.nio.file.Files
import java.util.UUID
@ -15,9 +15,9 @@ import org.enso.languageserver.data.{
import org.enso.languageserver.effect.ZioExec
import org.enso.languageserver.filemanager.{FileManager, FileSystem}
import org.enso.languageserver.http.server.ConnectionControllerFactory
import org.enso.languageserver.protocol.data.BinaryConnectionController
import org.enso.languageserver.protocol.data.envelope.InboundPayload
import org.enso.languageserver.websocket.data.factory.{
import org.enso.languageserver.protocol.binary.BinaryConnectionController
import org.enso.languageserver.protocol.binary.InboundPayload
import org.enso.languageserver.websocket.binary.factory.{
InboundMessageFactory,
SessionInitFactory
}

View File

@ -1,4 +1,4 @@
package org.enso.languageserver.websocket.data
package org.enso.languageserver.websocket.binary
import java.io.File
import java.nio.ByteBuffer
@ -6,13 +6,13 @@ import java.util.UUID
import com.google.flatbuffers.FlatBufferBuilder
import org.apache.commons.io.FileUtils
import org.enso.languageserver.protocol.data.envelope.{
import org.enso.languageserver.protocol.binary.{
InboundPayload,
OutboundMessage,
OutboundPayload
}
import org.enso.languageserver.protocol.data.filemanager.FileContentsReply
import org.enso.languageserver.websocket.data.factory.{
import org.enso.languageserver.protocol.binary.FileContentsReply
import org.enso.languageserver.websocket.binary.factory.{
InboundMessageFactory,
PathFactory,
ReadFileCommandFactory,

View File

@ -1,4 +1,4 @@
package org.enso.languageserver.websocket.data
package org.enso.languageserver.websocket.binary
import java.nio.ByteBuffer
@ -14,7 +14,7 @@ import org.enso.languageserver.http.server.{
BinaryWebSocketServer,
ConnectionControllerFactory
}
import org.enso.languageserver.protocol.data.InboundMessageDecoder
import org.enso.languageserver.protocol.binary.InboundMessageDecoder
import org.enso.languageserver.util.binary.{
BinaryDecoder,
BinaryEncoder,

View File

@ -1,14 +1,14 @@
package org.enso.languageserver.websocket.data
package org.enso.languageserver.websocket.binary
import java.util.UUID
import com.google.flatbuffers.FlatBufferBuilder
import org.enso.languageserver.protocol.data.envelope.{
import org.enso.languageserver.protocol.binary.{
InboundPayload,
OutboundMessage,
OutboundPayload
}
import org.enso.languageserver.websocket.data.factory.{
import org.enso.languageserver.websocket.binary.factory.{
InboundMessageFactory,
SessionInitFactory
}

View File

@ -1,8 +1,8 @@
package org.enso.languageserver.websocket.data
package org.enso.languageserver.websocket.binary
import java.nio.ByteBuffer
import org.enso.languageserver.protocol.data.envelope.OutboundMessage
import org.enso.languageserver.protocol.binary.OutboundMessage
import org.enso.languageserver.util.binary.{BinaryDecoder, DecodingFailure}
object OutboundMessageDecoder extends BinaryDecoder[OutboundMessage] {

View File

@ -1,13 +1,13 @@
package org.enso.languageserver.websocket.data
package org.enso.languageserver.websocket.binary
import java.nio.ByteBuffer
import java.util.UUID
import org.enso.languageserver.protocol.data.envelope.{
import org.enso.languageserver.protocol.binary.{
OutboundMessage,
OutboundPayload
OutboundPayload,
VisualisationUpdate => BinaryVisualisationUpdate
}
import org.enso.languageserver.protocol.data.executioncontext
import org.enso.languageserver.runtime.ContextRegistryProtocol.{
VisualisationContext,
VisualisationUpdate
@ -37,8 +37,8 @@ class VisualisationProtocolTest extends BaseBinaryServerTest with Eventually {
//then
msg.payloadType() shouldBe OutboundPayload.VISUALISATION_UPDATE
val payload = msg
.payload(new executioncontext.VisualisationUpdate)
.asInstanceOf[executioncontext.VisualisationUpdate]
.payload(new BinaryVisualisationUpdate)
.asInstanceOf[BinaryVisualisationUpdate]
payload.dataAsByteBuffer().compareTo(ByteBuffer.wrap(data)) shouldBe 0
payload
.visualisationContext()

View File

@ -1,11 +1,10 @@
package org.enso.languageserver.websocket.data.factory
package org.enso.languageserver.websocket.binary.factory
import java.util.UUID
import com.google.flatbuffers.FlatBufferBuilder
import org.enso.languageserver.protocol.data.envelope.InboundMessage
import org.enso.languageserver.protocol.data.factory.EnsoUuidFactory
import org.enso.languageserver.protocol.data.util.EnsoUUID
import org.enso.languageserver.protocol.binary.{EnsoUUID, InboundMessage}
import org.enso.languageserver.protocol.binary.factory.EnsoUuidFactory
object InboundMessageFactory {
@ -17,7 +16,7 @@ object InboundMessageFactory {
)(implicit builder: FlatBufferBuilder): Int = {
InboundMessage.startInboundMessage(builder)
val reqId = EnsoUuidFactory.create(requestId)
InboundMessage.addRequestId(builder, reqId)
InboundMessage.addMessageId(builder, reqId)
maybeCorrelationId.foreach { uuid =>
val corId = EnsoUuidFactory.create(uuid)
InboundMessage.addCorrelationId(builder, corId)

View File

@ -1,10 +1,10 @@
package org.enso.languageserver.websocket.data.factory
package org.enso.languageserver.websocket.binary.factory
import java.util.UUID
import com.google.flatbuffers.FlatBufferBuilder
import org.enso.languageserver.protocol.data.factory.EnsoUuidFactory
import org.enso.languageserver.protocol.data.filemanager.Path
import org.enso.languageserver.protocol.binary.Path
import org.enso.languageserver.protocol.binary.factory.EnsoUuidFactory
object PathFactory {

View File

@ -1,7 +1,7 @@
package org.enso.languageserver.websocket.data.factory
package org.enso.languageserver.websocket.binary.factory
import com.google.flatbuffers.FlatBufferBuilder
import org.enso.languageserver.protocol.data.filemanager.ReadFileCommand
import org.enso.languageserver.protocol.binary.ReadFileCommand
object ReadFileCommandFactory {

View File

@ -1,10 +1,10 @@
package org.enso.languageserver.websocket.data.factory
package org.enso.languageserver.websocket.binary.factory
import java.util.UUID
import com.google.flatbuffers.FlatBufferBuilder
import org.enso.languageserver.protocol.data.factory.EnsoUuidFactory
import org.enso.languageserver.protocol.data.session.InitSessionCommand
import org.enso.languageserver.protocol.binary.InitSessionCommand
import org.enso.languageserver.protocol.binary.factory.EnsoUuidFactory
object SessionInitFactory {

View File

@ -1,7 +1,7 @@
package org.enso.languageserver.websocket.data.factory
package org.enso.languageserver.websocket.binary.factory
import com.google.flatbuffers.FlatBufferBuilder
import org.enso.languageserver.protocol.data.filemanager.WriteFileCommand
import org.enso.languageserver.protocol.binary.WriteFileCommand
object WriteFileCommandFactory {

View File

@ -1,4 +1,4 @@
package org.enso.languageserver.websocket.rpc
package org.enso.languageserver.websocket.json
import java.nio.file.Files
import java.util.UUID
@ -15,9 +15,9 @@ import org.enso.languageserver.filemanager.{
FileSystem,
ReceivesTreeUpdatesHandler
}
import org.enso.languageserver.protocol.rpc.{
JsonRpc,
RpcConnectionControllerFactory
import org.enso.languageserver.protocol.json.{
JsonConnectionControllerFactory,
JsonRpc
}
import org.enso.languageserver.runtime.ContextRegistry
import org.enso.languageserver.session.SessionRouter
@ -66,7 +66,7 @@ class BaseServerTest extends JsonRpcServerTestKit {
lazy val capabilityRouter =
system.actorOf(CapabilityRouter.props(bufferRegistry, fileEventRegistry))
new RpcConnectionControllerFactory(
new JsonConnectionControllerFactory(
bufferRegistry,
capabilityRouter,
fileManager,

View File

@ -1,10 +1,10 @@
package org.enso.languageserver.websocket.rpc
package org.enso.languageserver.websocket.json
import java.io.File
import java.util.UUID
import io.circe.literal._
import org.enso.languageserver.websocket.rpc.{
import org.enso.languageserver.websocket.json.{
ExecutionContextJsonMessages => json
}
import org.enso.polyglot.runtime.Runtime.Api

View File

@ -1,4 +1,4 @@
package org.enso.languageserver.websocket.rpc
package org.enso.languageserver.websocket.json
import org.enso.polyglot.runtime.Runtime.Api
import io.circe.literal._

View File

@ -1,4 +1,4 @@
package org.enso.languageserver.websocket.rpc
package org.enso.languageserver.websocket.json
import java.nio.file.attribute.BasicFileAttributes
import java.nio.file.{Files, Paths}

View File

@ -1,4 +1,4 @@
package org.enso.languageserver.websocket.rpc
package org.enso.languageserver.websocket.json
import java.io.File

View File

@ -1,4 +1,4 @@
package org.enso.languageserver.websocket.rpc
package org.enso.languageserver.websocket.json
import io.circe.literal._

View File

@ -1,4 +1,4 @@
package org.enso.languageserver.websocket.rpc
package org.enso.languageserver.websocket.json
import java.nio.file.{Files, Paths}

View File

@ -1,4 +1,4 @@
package org.enso.languageserver.websocket.rpc
package org.enso.languageserver.websocket.json
import io.circe.literal._

View File

@ -1,4 +1,4 @@
package org.enso.languageserver.websocket.rpc
package org.enso.languageserver.websocket.json
import akka.testkit.TestProbe
import io.circe.literal._

View File

@ -1,4 +1,4 @@
package org.enso.languageserver.websocket.rpc
package org.enso.languageserver.websocket.json
import java.util.UUID
import io.circe.literal._

View File

@ -4,7 +4,7 @@
<!-- encoders are assigned the type
ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%-15thread] %-5level %msg%n</pattern>
<pattern>%d{HH:mm:ss.SSS} %-5level [%-15thread] %-36logger{36} %msg%n</pattern>
</encoder>
</appender>

View File

@ -3,7 +3,7 @@ package org.enso.projectmanager.data
/**
* Sockets that a language server listens on.
*
* @param rpcSocket a socket used for RPC protocol
* @param dataSocket a socket used fot data protocol
* @param jsonSocket a socket used for JSON-RPC protocol
* @param binarySocket a socket used fot binary protocol
*/
case class LanguageServerSockets(rpcSocket: Socket, dataSocket: Socket)
case class LanguageServerSockets(jsonSocket: Socket, binarySocket: Socket)

View File

@ -3,6 +3,7 @@ package org.enso.projectmanager.infrastructure.languageserver
import java.util.UUID
import akka.actor.{Actor, ActorLogging, Cancellable, Props, Scheduler}
import akka.stream.SubscriptionWithCancelException.StageWasCompleted
import io.circe.parser._
import org.enso.projectmanager.data.Socket
import org.enso.projectmanager.infrastructure.http.WebSocketConnection.{
@ -121,16 +122,14 @@ class HeartbeatSession(
}
private def socketClosureStage(cancellable: Cancellable): Receive = {
case WebSocketStreamClosed =>
case WebSocketStreamClosed | WebSocketStreamFailure(StageWasCompleted) =>
context.stop(self)
cancellable.cancel()
()
case WebSocketStreamFailure(th) =>
log.error(s"An error occurred during closing web socket", th)
log.error(th, s"An error occurred during closing web socket")
context.stop(self)
cancellable.cancel()
()
case SocketClosureTimeout =>
log.error(s"Socket closure timed out")

View File

@ -43,8 +43,8 @@ object ProjectManagementApi {
case class Params(projectId: UUID)
case class Result(
languageServerRpcAddress: Socket,
languageServerDataAddress: Socket
languageServerJsonAddress: Socket,
languageServerBinaryAddress: Socket
)
implicit val hasParams = new HasParams[this.type] {

View File

@ -71,7 +71,7 @@ class ProjectOpenHandler[F[+_, +_]: Exec](
replyTo ! ResponseResult(
ProjectOpen,
id,
ProjectOpen.Result(sockets.rpcSocket, sockets.dataSocket)
ProjectOpen.Result(sockets.jsonSocket, sockets.binarySocket)
)
cancellable.cancel()
context.stop(self)

View File

@ -4,7 +4,7 @@
<!-- encoders are assigned the type
ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%-15thread] %-5level %msg%n</pattern>
<pattern>%d{HH:mm:ss.SSS} [%-15thread] %-5level %logger{36} %msg%n</pattern>
</encoder>
</appender>