mirror of
https://github.com/enso-org/enso.git
synced 2024-11-23 16:18:23 +03:00
Use system dispatcher for ZIO (#3534)
Changelog: - update: reuse system dispatcher for ZIO library instead of creating an extra one.
This commit is contained in:
parent
c72a6582bc
commit
1e7047f26f
@ -12,7 +12,7 @@ import org.enso.jsonrpc.JsonRpcServer
|
||||
import org.enso.languageserver.boot.DeploymentType.{Azure, Desktop}
|
||||
import org.enso.languageserver.capability.CapabilityRouter
|
||||
import org.enso.languageserver.data._
|
||||
import org.enso.languageserver.effect.ZioExec
|
||||
import org.enso.languageserver.effect
|
||||
import org.enso.languageserver.filemanager._
|
||||
import org.enso.languageserver.http.server.BinaryWebSocketServer
|
||||
import org.enso.languageserver.io._
|
||||
@ -88,7 +88,18 @@ class MainModule(serverConfig: LanguageServerConfig, logLevel: LogLevel) {
|
||||
)
|
||||
log.trace("Created Language Server config [{}].", languageServerConfig)
|
||||
|
||||
val zioExec = ZioExec(zio.Runtime.default)
|
||||
implicit val system: ActorSystem =
|
||||
ActorSystem(
|
||||
serverConfig.name,
|
||||
None,
|
||||
None,
|
||||
Some(serverConfig.computeExecutionContext)
|
||||
)
|
||||
log.trace(s"Created ActorSystem $system.")
|
||||
|
||||
private val zioRuntime =
|
||||
effect.Runtime.fromExecutionContext(system.dispatcher)
|
||||
private val zioExec = effect.ZioExec(zioRuntime)
|
||||
log.trace("Created ZIO executor [{}].", zioExec)
|
||||
|
||||
val fileSystem: FileSystem = new FileSystem
|
||||
@ -98,15 +109,6 @@ class MainModule(serverConfig: LanguageServerConfig, logLevel: LogLevel) {
|
||||
Sha3_224VersionCalculator
|
||||
log.trace("Created Version Calculator [{}].", versionCalculator)
|
||||
|
||||
implicit val system =
|
||||
ActorSystem(
|
||||
serverConfig.name,
|
||||
None,
|
||||
None,
|
||||
Some(serverConfig.computeExecutionContext)
|
||||
)
|
||||
log.trace(s"Created ActorSystem $system.")
|
||||
|
||||
val sqlDatabase =
|
||||
DeploymentType.fromEnvironment() match {
|
||||
case Desktop =>
|
||||
|
@ -0,0 +1,17 @@
|
||||
package org.enso.languageserver.effect
|
||||
|
||||
import scala.concurrent.ExecutionContext
|
||||
|
||||
object Runtime {
|
||||
|
||||
/** Create ZIO [[zio.Runtime]] from execution context.
|
||||
*
|
||||
* @param ec the execution context to use in the runtime
|
||||
* @return a new instance of [[zio.Runtime]]
|
||||
*/
|
||||
def fromExecutionContext(ec: ExecutionContext): zio.Runtime[zio.ZEnv] =
|
||||
zio.Runtime.unsafeFromLayer(
|
||||
zio.ZEnv.live,
|
||||
zio.internal.Platform.fromExecutionContext(ec)
|
||||
)
|
||||
}
|
Loading…
Reference in New Issue
Block a user