[go: nahoru, domu]

Skip to content
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

Integrating Runtime Version Manager with Project Manager #1285

Merged
merged 18 commits into from
Nov 16, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Implement engine version management
  • Loading branch information
radeusgd committed Nov 16, 2020
commit 178c192b2167a59393d04b43053dcbc5047bb800
4 changes: 2 additions & 2 deletions docs/language-server/protocol-project-manager.md
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ interface TaskStartNotification {
* May be missing, as it is not always known, for example when downloading a
* file of unknown size or waiting on a lock.
*/
total?: Int;
total?: Long;
}
```

Expand All @@ -529,7 +529,7 @@ interface TaskUpdateNotification {
message?: String;

/** Indicates amount of progress, for example: count of processed bytes. */
done: Int;
done: Long;
}
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ class CLIRuntimeVersionManagementUserInterface(
) extends RuntimeVersionManagementUserInterface {

/** @inheritdoc */
override def trackProgress(task: TaskProgress[_]): Unit =
override def trackProgress(message: String, task: TaskProgress[_]): Unit = {
logInfo(message)
if (cliOptions.hideProgress) ()
else ProgressBar.waitWithProgress(task)
}

private val logger = Logger[CLIRuntimeVersionManagementUserInterface]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ object LauncherUpgrader {
} else {
logger.warn(
s"A more recent launcher version (at least " +
s"${upgradeRequiredError.expectedLauncherVersion}) is required to " +
s"${upgradeRequiredError.expectedVersion}) is required to " +
s"continue."
)
CLIOutput.askConfirmation(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import org.enso.projectmanager.protocol.{
ManagerClientControllerFactory
}
import org.enso.projectmanager.service.config.GlobalConfigService
import org.enso.projectmanager.service.versionmanagement.RuntimeVersionManagementService
import org.enso.projectmanager.service.{
MonadicProjectValidator,
ProjectService,
Expand Down Expand Up @@ -105,12 +106,16 @@ class MainModule[

lazy val globalConfigService = new GlobalConfigService[F](DefaultManagers)

lazy val runtimeVersionManagementService =
new RuntimeVersionManagementService[F](DefaultManagers)

lazy val clientControllerFactory =
new ManagerClientControllerFactory[F](
system,
projectService,
globalConfigService,
config.timeout
system = system,
projectService = projectService,
globalConfigService = globalConfigService,
runtimeVersionManagementService = runtimeVersionManagementService,
timeoutConfig = config.timeout
)

lazy val server = new JsonRpcServer(JsonRpc.protocol, clientControllerFactory)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import org.enso.projectmanager.protocol.ProjectManagementApi._
import org.enso.projectmanager.requesthandler._
import org.enso.projectmanager.service.ProjectServiceApi
import org.enso.projectmanager.service.config.GlobalConfigServiceApi
import org.enso.projectmanager.service.versionmanagement.RuntimeVersionManagementServiceApi
import org.enso.projectmanager.util.UnhandledLogging

import scala.annotation.unused
Expand All @@ -31,6 +32,7 @@ class ClientController[F[+_, +_]: Exec: CovariantFlatMap](
clientId: UUID,
projectService: ProjectServiceApi[F],
globalConfigService: GlobalConfigServiceApi[F],
runtimeVersionManagementService: RuntimeVersionManagementServiceApi[F],
timeoutConfig: TimeoutConfig
) extends Actor
with ActorLogging
Expand All @@ -55,10 +57,20 @@ class ClientController[F[+_, +_]: Exec: CovariantFlatMap](
.props[F](clientId, projectService, timeoutConfig.requestTimeout),
ProjectRename -> ProjectRenameHandler
.props[F](projectService, timeoutConfig.requestTimeout),
EngineListInstalled -> NotImplementedHandler.props,
EngineListAvailable -> NotImplementedHandler.props,
EngineInstall -> NotImplementedHandler.props,
EngineUninstall -> NotImplementedHandler.props,
EngineListInstalled -> EngineListInstalledHandler.props(
runtimeVersionManagementService,
timeoutConfig.requestTimeout
),
EngineListAvailable -> EngineListAvailableHandler.props(
runtimeVersionManagementService,
timeoutConfig.requestTimeout
),
EngineInstall -> EngineInstallHandler.props(
runtimeVersionManagementService
),
EngineUninstall -> EngineUninstallHandler.props(
runtimeVersionManagementService
),
ConfigGet -> ConfigGetHandler
.props(globalConfigService, timeoutConfig.requestTimeout),
ConfigSet -> ConfigSetHandler
Expand Down Expand Up @@ -104,14 +116,16 @@ object ClientController {
clientId: UUID,
projectService: ProjectServiceApi[F],
globalConfigService: GlobalConfigServiceApi[F],
runtimeVersionManagementService: RuntimeVersionManagementServiceApi[F],
config: TimeoutConfig
): Props =
Props(
new ClientController(
clientId = clientId,
projectService = projectService,
globalConfigService = globalConfigService,
timeoutConfig = config: TimeoutConfig
clientId = clientId,
projectService = projectService,
globalConfigService = globalConfigService,
runtimeVersionManagementService = runtimeVersionManagementService,
timeoutConfig = config: TimeoutConfig
)
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import org.enso.projectmanager.control.core.CovariantFlatMap
import org.enso.projectmanager.control.effect.Exec
import org.enso.projectmanager.service.ProjectServiceApi
import org.enso.projectmanager.service.config.GlobalConfigServiceApi
import org.enso.projectmanager.service.versionmanagement.RuntimeVersionManagementServiceApi

/** Project manager client controller factory.
*
Expand All @@ -18,6 +19,7 @@ class ManagerClientControllerFactory[F[+_, +_]: Exec: CovariantFlatMap](
system: ActorSystem,
projectService: ProjectServiceApi[F],
globalConfigService: GlobalConfigServiceApi[F],
runtimeVersionManagementService: RuntimeVersionManagementServiceApi[F],
timeoutConfig: TimeoutConfig
) extends ClientControllerFactory {

Expand All @@ -29,7 +31,13 @@ class ManagerClientControllerFactory[F[+_, +_]: Exec: CovariantFlatMap](
override def createClientController(clientId: UUID): ActorRef =
system.actorOf(
ClientController
.props[F](clientId, projectService, globalConfigService, timeoutConfig),
.props[F](
clientId,
projectService,
globalConfigService,
runtimeVersionManagementService,
timeoutConfig
),
s"jsonrpc-connection-controller-$clientId"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ object ProjectManagementApi {
taskId: UUID,
relatedOperation: String,
unit: ProgressUnit,
total: Option[Int]
total: Option[Long]
)

implicit val hasParams = new HasParams[this.type] {
Expand All @@ -134,7 +134,7 @@ object ProjectManagementApi {
case class Params(
taskId: UUID,
message: Option[String],
done: Int
done: Long
)

implicit val hasParams = new HasParams[this.type] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ import scala.concurrent.duration.FiniteDuration
class ConfigDeleteHandler[F[+_, +_]: Exec: CovariantFlatMap](
service: GlobalConfigServiceApi[F],
requestTimeout: FiniteDuration
) extends TimedRequestHandler[F, GlobalConfigServiceFailure](requestTimeout) {
) extends RequestHandler[F, GlobalConfigServiceFailure](
ConfigDelete,
Some(requestTimeout)
) {
override def handleRequest
: PartialFunction[Any, F[GlobalConfigServiceFailure, Any]] = {
case Request(ConfigDelete, id, params: ConfigDelete.Params) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ import scala.concurrent.duration.FiniteDuration
class ConfigGetHandler[F[+_, +_]: Exec: CovariantFlatMap](
service: GlobalConfigServiceApi[F],
requestTimeout: FiniteDuration
) extends TimedRequestHandler[F, GlobalConfigServiceFailure](requestTimeout) {
) extends RequestHandler[F, GlobalConfigServiceFailure](
ConfigGet,
Some(requestTimeout)
) {
override def handleRequest
: PartialFunction[Any, F[GlobalConfigServiceFailure, Any]] = {
case Request(ConfigGet, id, params: ConfigGet.Params) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ import scala.concurrent.duration.FiniteDuration
class ConfigSetHandler[F[+_, +_]: Exec: CovariantFlatMap](
service: GlobalConfigServiceApi[F],
requestTimeout: FiniteDuration
) extends TimedRequestHandler[F, GlobalConfigServiceFailure](requestTimeout) {
) extends RequestHandler[F, GlobalConfigServiceFailure](
ConfigSet,
Some(requestTimeout)
) {
override def handleRequest
: PartialFunction[Any, F[GlobalConfigServiceFailure, Any]] = {
case Request(ConfigSet, id, params: ConfigSet.Params) =>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package org.enso.projectmanager.requesthandler

import akka.actor.Props
import org.enso.jsonrpc.{Request, ResponseResult, Unused}
import org.enso.projectmanager.control.core.CovariantFlatMap
import org.enso.projectmanager.control.core.syntax._
import org.enso.projectmanager.control.effect.Exec
import org.enso.projectmanager.protocol.ProjectManagementApi.EngineInstall
import org.enso.projectmanager.requesthandler.ProjectServiceFailureMapper.failureMapper
import org.enso.projectmanager.service.ProjectServiceFailure
import org.enso.projectmanager.service.versionmanagement.RuntimeVersionManagementServiceApi

class EngineInstallHandler[F[+_, +_]: Exec: CovariantFlatMap](
service: RuntimeVersionManagementServiceApi[F]
) extends RequestHandler[F, ProjectServiceFailure](EngineInstall, None) {
override def handleRequest
: PartialFunction[Any, F[ProjectServiceFailure, Any]] = {
case Request(EngineInstall, id, params: EngineInstall.Params) =>
val progressTracker = sender()
for {
_ <- service.installEngine(
progressTracker,
params.version,
params.forceInstallBroken.getOrElse(false)
)
} yield ResponseResult(EngineInstall, id, Unused)
}
}

object EngineInstallHandler {
def props[F[+_, +_]: Exec: CovariantFlatMap](
service: RuntimeVersionManagementServiceApi[F]
): Props = Props(new EngineInstallHandler[F](service))
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package org.enso.projectmanager.requesthandler

import akka.actor.Props
import org.enso.jsonrpc.{Request, ResponseResult, Unused}
import org.enso.projectmanager.control.core.CovariantFlatMap
import org.enso.projectmanager.control.core.syntax._
import org.enso.projectmanager.control.effect.Exec
import org.enso.projectmanager.protocol.ProjectManagementApi.EngineListAvailable
import org.enso.projectmanager.requesthandler.ProjectServiceFailureMapper.failureMapper
import org.enso.projectmanager.service.ProjectServiceFailure
import org.enso.projectmanager.service.versionmanagement.RuntimeVersionManagementServiceApi

import scala.concurrent.duration.FiniteDuration

class EngineListAvailableHandler[F[+_, +_]: Exec: CovariantFlatMap](
service: RuntimeVersionManagementServiceApi[F],
requestTimeout: FiniteDuration
) extends RequestHandler[F, ProjectServiceFailure](
EngineListAvailable,
Some(requestTimeout)
) {
override def handleRequest
: PartialFunction[Any, F[ProjectServiceFailure, Any]] = {
case Request(EngineListAvailable, id, Unused) =>
for {
result <- service.listAvailableEngines()
} yield ResponseResult(
EngineListAvailable,
id,
EngineListAvailable.Result(result)
)
}
}

object EngineListAvailableHandler {
def props[F[+_, +_]: Exec: CovariantFlatMap](
service: RuntimeVersionManagementServiceApi[F],
requestTimeout: FiniteDuration
): Props = Props(new EngineListAvailableHandler[F](service, requestTimeout))
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package org.enso.projectmanager.requesthandler

import akka.actor.Props
import org.enso.jsonrpc.{Request, ResponseResult, Unused}
import org.enso.projectmanager.control.core.CovariantFlatMap
import org.enso.projectmanager.control.core.syntax._
import org.enso.projectmanager.control.effect.Exec
import org.enso.projectmanager.protocol.ProjectManagementApi.EngineListInstalled
import org.enso.projectmanager.requesthandler.ProjectServiceFailureMapper.failureMapper
import org.enso.projectmanager.service.ProjectServiceFailure
import org.enso.projectmanager.service.versionmanagement.RuntimeVersionManagementServiceApi

import scala.concurrent.duration.FiniteDuration

class EngineListInstalledHandler[F[+_, +_]: Exec: CovariantFlatMap](
service: RuntimeVersionManagementServiceApi[F],
requestTimeout: FiniteDuration
) extends RequestHandler[F, ProjectServiceFailure](
EngineListInstalled,
Some(requestTimeout)
) {
override def handleRequest
: PartialFunction[Any, F[ProjectServiceFailure, Any]] = {
case Request(EngineListInstalled, id, Unused) =>
for {
result <- service.listInstalledEngines()
} yield ResponseResult(
EngineListInstalled,
id,
EngineListInstalled.Result(result)
)
}
}

object EngineListInstalledHandler {
def props[F[+_, +_]: Exec: CovariantFlatMap](
service: RuntimeVersionManagementServiceApi[F],
requestTimeout: FiniteDuration
): Props = Props(new EngineListInstalledHandler[F](service, requestTimeout))
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package org.enso.projectmanager.requesthandler

import akka.actor.Props
import org.enso.jsonrpc.{Request, ResponseResult, Unused}
import org.enso.projectmanager.control.core.CovariantFlatMap
import org.enso.projectmanager.control.core.syntax._
import org.enso.projectmanager.control.effect.Exec
import org.enso.projectmanager.protocol.ProjectManagementApi.EngineUninstall
import org.enso.projectmanager.requesthandler.ProjectServiceFailureMapper.failureMapper
import org.enso.projectmanager.service.ProjectServiceFailure
import org.enso.projectmanager.service.versionmanagement.RuntimeVersionManagementServiceApi

class EngineUninstallHandler[F[+_, +_]: Exec: CovariantFlatMap](
service: RuntimeVersionManagementServiceApi[F]
) extends RequestHandler[F, ProjectServiceFailure](EngineUninstall, None) {
override def handleRequest
: PartialFunction[Any, F[ProjectServiceFailure, Any]] = {
case Request(EngineUninstall, id, params: EngineUninstall.Params) =>
val progressTracker = sender()
for {
_ <- service.uninstallEngine(progressTracker, params.version)
} yield ResponseResult(EngineUninstall, id, Unused)
}
}

object EngineUninstallHandler {
def props[F[+_, +_]: Exec: CovariantFlatMap](
service: RuntimeVersionManagementServiceApi[F]
): Props = Props(new EngineUninstallHandler[F](service))
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,17 @@ object ProjectServiceFailureMapper {
case CannotRemoveOpenProject => CannotRemoveOpenProjectError
case ProjectOperationTimeout => ServiceError
case LanguageServerFailure(msg) => LanguageServerError(msg)
case ProjectManagerUpgradeRequiredFailure(version) =>
ProjectManagerUpgradeRequired(version)
case MissingComponentFailure(msg) => MissingComponentError(msg)
case BrokenComponentFailure(msg) => BrokenComponentError(msg)
case ComponentInstallationFailure(msg) => ComponentInstallationError(msg)
case ComponentRepositoryAccessFailure(msg) =>
ComponentRepositoryUnavailable(msg)
case ComponentUninstallationFailure(msg) =>
ComponentUninstallationError(msg)
}

implicit val failureMapper: FailureMapper[ProjectServiceFailure] =
(failure: ProjectServiceFailure) => mapFailure(failure)
}
Loading