mirror of
https://github.com/enso-org/enso.git
synced 2025-01-03 17:14:33 +03:00
Async Ydoc initialization (#10290)
close #10265 Changelog: - add: YdocInitialization component
This commit is contained in:
parent
20998e30b0
commit
06a73606b9
@ -63,7 +63,7 @@ public class RepoInitialization implements InitializationComponent {
|
||||
return initSuggestionsRepo()
|
||||
.whenCompleteAsync(
|
||||
(res, err) -> {
|
||||
if (err == null && res != null) {
|
||||
if (err == null) {
|
||||
isInitialized = true;
|
||||
}
|
||||
lock.release();
|
||||
|
@ -0,0 +1,29 @@
|
||||
package org.enso.languageserver.boot.resource;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
import org.enso.ydoc.Ydoc;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public final class YdocInitialization extends LockedInitialization {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
private final Ydoc ydoc;
|
||||
|
||||
public YdocInitialization(Executor executor, Ydoc ydoc) {
|
||||
super(executor);
|
||||
this.ydoc = ydoc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initComponent() {
|
||||
logger.info("Starting Ydoc server...");
|
||||
try {
|
||||
ydoc.start();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
logger.info("Started Ydoc server.");
|
||||
}
|
||||
}
|
@ -440,6 +440,12 @@ class MainModule(serverConfig: LanguageServerConfig, logLevel: Level) {
|
||||
|
||||
private val jsonRpcProtocolFactory = new JsonRpcProtocolFactory
|
||||
|
||||
private val ydoc = Ydoc
|
||||
.builder()
|
||||
.hostname(applicationConfig.ydoc.hostname)
|
||||
.port(applicationConfig.ydoc.port)
|
||||
.build()
|
||||
|
||||
private val initializationComponent =
|
||||
ResourcesInitialization(
|
||||
system.eventStream,
|
||||
@ -447,7 +453,8 @@ class MainModule(serverConfig: LanguageServerConfig, logLevel: Level) {
|
||||
jsonRpcProtocolFactory,
|
||||
suggestionsRepo,
|
||||
context,
|
||||
zioRuntime
|
||||
zioRuntime,
|
||||
ydoc
|
||||
)(system.dispatcher)
|
||||
|
||||
private val jsonRpcControllerFactory = new JsonConnectionControllerFactory(
|
||||
@ -510,14 +517,6 @@ class MainModule(serverConfig: LanguageServerConfig, logLevel: Level) {
|
||||
)
|
||||
log.trace("Created Binary WebSocket Server [{}].", binaryServer)
|
||||
|
||||
private val ydoc = Ydoc
|
||||
.builder()
|
||||
.hostname(applicationConfig.ydoc.hostname)
|
||||
.port(applicationConfig.ydoc.port)
|
||||
.build()
|
||||
ydoc.start()
|
||||
log.debug("Started Ydoc server.")
|
||||
|
||||
log.info(
|
||||
"Main module of the Language Server initialized with config [{}].",
|
||||
languageServerConfig
|
||||
|
@ -10,11 +10,13 @@ import org.enso.languageserver.boot.resource.{
|
||||
RepoInitialization,
|
||||
SequentialResourcesInitialization,
|
||||
TruffleContextInitialization,
|
||||
YdocInitialization,
|
||||
ZioRuntimeInitialization
|
||||
}
|
||||
import org.enso.languageserver.data.ProjectDirectoriesConfig
|
||||
import org.enso.languageserver.effect
|
||||
import org.enso.searcher.memory.InMemorySuggestionsRepo
|
||||
import org.enso.ydoc.Ydoc
|
||||
import org.graalvm.polyglot.Context
|
||||
|
||||
import scala.concurrent.ExecutionContextExecutor
|
||||
@ -32,6 +34,7 @@ object ResourcesInitialization {
|
||||
* @param suggestionsRepo the suggestions repo
|
||||
* @param truffleContext the runtime context
|
||||
* @param runtime the runtime to run effects
|
||||
* @param ydoc the ydoc server
|
||||
* @return the initialization component
|
||||
*/
|
||||
def apply(
|
||||
@ -40,7 +43,8 @@ object ResourcesInitialization {
|
||||
protocolFactory: ProtocolFactory,
|
||||
suggestionsRepo: InMemorySuggestionsRepo,
|
||||
truffleContext: Context,
|
||||
runtime: effect.Runtime
|
||||
runtime: effect.Runtime,
|
||||
ydoc: Ydoc
|
||||
)(implicit ec: ExecutionContextExecutor): InitializationComponent = {
|
||||
new SequentialResourcesInitialization(
|
||||
ec,
|
||||
@ -54,7 +58,8 @@ object ResourcesInitialization {
|
||||
eventStream,
|
||||
suggestionsRepo
|
||||
),
|
||||
new TruffleContextInitialization(ec, truffleContext, eventStream)
|
||||
new TruffleContextInitialization(ec, truffleContext, eventStream),
|
||||
new YdocInitialization(ec, ydoc)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user