[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
Some more docs
  • Loading branch information
radeusgd committed Nov 16, 2020
commit 0f41c766ff519ae84b5680c2e62745ee5d977540
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import org.enso.runtimeversionmanager.releases.{
SimpleReleaseProvider
}

/** Represents the default Enso repository providing releases for the launcher.
/** Represents the default Enso repository providing releases of the launcher.
*
* In test mode, the default GitHub repository can be overridden with a local
* filesystem-backed repository.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ trait ProgressReporter {
/** Called when a long-running task is started.
*
* Can be used to track its progress.
*
* @param message message associated with the task
* @param task the long running task to track
*/
def trackProgress(message: String, task: TaskProgress[_]): Unit
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import org.enso.projectmanager.service.{
ProjectServiceFailure,
ValidationFailure
}
import org.enso.projectmanager.versionmanagement.DefaultManagers
import org.enso.projectmanager.versionmanagement.DefaultDistributionConfiguration

import scala.concurrent.ExecutionContext

Expand Down Expand Up @@ -104,10 +104,11 @@ class MainModule[
languageServerGateway
)

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

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

lazy val clientControllerFactory =
new ManagerClientControllerFactory[F](
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@ import io.circe.Json
import org.enso.projectmanager.control.effect.{ErrorChannel, Sync}
import org.enso.projectmanager.service.config.GlobalConfigServiceFailure.ConfigurationFileAccessFailure
import org.enso.projectmanager.service.versionmanagement.NoOpInterface
import org.enso.projectmanager.versionmanagement.DistributionManagementConfiguration
import org.enso.projectmanager.versionmanagement.DistributionConfiguration
import org.enso.runtimeversionmanager.config.GlobalConfigurationManager

/** Implementation of global configuration management logic.
*
* @param managers a distribution configuration
* @param distributionConfiguration a distribution configuration
*/
class GlobalConfigService[F[+_, +_]: Sync: ErrorChannel](
managers: DistributionManagementConfiguration
distributionConfiguration: DistributionConfiguration
) extends GlobalConfigServiceApi[F] {

val configurationManager = new GlobalConfigurationManager(
managers.makeRuntimeVersionManager(new NoOpInterface),
managers.distributionManager
distributionConfiguration.makeRuntimeVersionManager(new NoOpInterface),
distributionConfiguration.distributionManager
)

override def getKey(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ import org.enso.projectmanager.service.ProjectServiceFailure.{
ComponentRepositoryAccessFailure,
ComponentUninstallationFailure
}
import org.enso.projectmanager.versionmanagement.DistributionManagementConfiguration
import org.enso.projectmanager.versionmanagement.DistributionConfiguration
import org.enso.runtimeversionmanager.components.ComponentMissingError

/** A facade for runtime version management logic that processes the requests
* using the [[RuntimeVersionManager]].
*
* @param managers a distribution configuration
* @param distributionConfiguration a distribution configuration
*/
class RuntimeVersionManagementService[F[+_, +_]: Sync: ErrorChannel](
override val managers: DistributionManagementConfiguration
override val distributionConfiguration: DistributionConfiguration
) extends RuntimeVersionManagementServiceApi[F]
with RuntimeVersionManagerMixin {

Expand Down Expand Up @@ -80,7 +80,8 @@ class RuntimeVersionManagementService[F[+_, +_]: Sync: ErrorChannel](
override def listAvailableEngines()
: F[ProjectServiceFailure, Seq[EngineVersion]] = Sync[F]
.blockingOp {
val engineReleaseProvider = managers.engineReleaseProvider
val engineReleaseProvider =
distributionConfiguration.engineReleaseProvider
engineReleaseProvider.fetchAllVersions().get.map { availableEngine =>
EngineVersion(availableEngine.version, availableEngine.markedAsBroken)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ import org.enso.projectmanager.service.ProjectServiceFailure.{
MissingComponentFailure,
ProjectManagerUpgradeRequiredFailure
}
import org.enso.projectmanager.versionmanagement.DistributionManagementConfiguration
import org.enso.projectmanager.versionmanagement.DistributionConfiguration
import org.enso.runtimeversionmanager.components._

/** A helper class that defines methods for creating the
* [[RuntimeVersionManager]] based on a
* [[DistributionManagementConfiguration]].
* [[DistributionConfiguration]].
*/
trait RuntimeVersionManagerMixin {

/** The distribution configuration to use. */
def managers: DistributionManagementConfiguration
def distributionConfiguration: DistributionConfiguration

/** Creates a [[RuntimeVersionManager]] that will send
* [[ProgressNotification]] to the specified [[ActorRef]] and with the
Expand All @@ -30,7 +30,7 @@ trait RuntimeVersionManagerMixin {
allowMissingComponents: Boolean,
allowBrokenComponents: Boolean
): RuntimeVersionManager =
managers.makeRuntimeVersionManager(
distributionConfiguration.makeRuntimeVersionManager(
new ControllerInterface(
progressTracker = progressTracker,
allowMissingComponents = allowMissingComponents,
Expand All @@ -45,7 +45,7 @@ trait RuntimeVersionManagerMixin {
* It is useful for simple queries, like listing installed versions.
*/
def makeReadOnlyVersionManager(): RuntimeVersionManager =
managers.makeRuntimeVersionManager(new NoOpInterface)
distributionConfiguration.makeRuntimeVersionManager(new NoOpInterface)

implicit class ErrorRecovery[F[+_, +_]: ErrorChannel, A](
fa: F[Throwable, A]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.enso.projectmanager.versionmanagement

import org.enso.runtimeversionmanager.Environment
import org.enso.runtimeversionmanager.components.{
RuntimeVersionManagementUserInterface,
RuntimeVersionManager
Expand All @@ -16,22 +17,41 @@ import org.enso.runtimeversionmanager.releases.engine.{
}
import org.enso.runtimeversionmanager.releases.graalvm.GraalCEReleaseProvider

object DefaultManagers extends DistributionManagementConfiguration {
/** Default distribution configuration to use for the Project Manager in
* production.
*
* The distribution manager and others need to be lazily initialized to ensure
* that they are initialized at runtime and not at build time if we try
* building a Native Image.
*/
object DefaultDistributionConfiguration extends DistributionConfiguration {

/** The default [[Environment]] implementation, with no overrides. */
object DefaultEnvironment extends Environment

// TODO [RW, AO] should the PM support portable distributions?
// If so, where will be the project-manager binary located with respect to
// the distribution root?
val distributionManager = new DistributionManager(DefaultEnvironment)
/** @inheritdoc */
lazy val distributionManager = new DistributionManager(DefaultEnvironment)

/** @inheritdoc */
lazy val lockManager = new FileLockManager(distributionManager.paths.locks)

/** @inheritdoc */
lazy val resourceManager = new ResourceManager(lockManager)

/** @inheritdoc */
lazy val temporaryDirectoryManager =
new TemporaryDirectoryManager(distributionManager, resourceManager)

/** @inheritdoc */
lazy val engineReleaseProvider: ReleaseProvider[EngineRelease] =
EngineRepository.defaultEngineReleaseProvider

private def runtimeReleaseProvider = GraalCEReleaseProvider

/** @inheritdoc */
def makeRuntimeVersionManager(
userInterface: RuntimeVersionManagementUserInterface
): RuntimeVersionManager =
Expand All @@ -41,6 +61,6 @@ object DefaultManagers extends DistributionManagementConfiguration {
temporaryDirectoryManager = temporaryDirectoryManager,
resourceManager = resourceManager,
engineReleaseProvider = engineReleaseProvider,
runtimeReleaseProvider = GraalCEReleaseProvider
runtimeReleaseProvider = runtimeReleaseProvider
)
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import org.enso.runtimeversionmanager.releases.engine.EngineRelease
* a distribution located in a specific place within the filesystem. It can
* also be overridden in tests.
*/
trait DistributionManagementConfiguration {
trait DistributionConfiguration {

/** A [[DistributionManager]] instance. */
def distributionManager: DistributionManager
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package org.enso.projectmanager

import java.nio.file.Path

import org.enso.projectmanager.versionmanagement.DistributionManagementConfiguration
import org.enso.projectmanager.versionmanagement.DistributionConfiguration
import org.enso.runtimeversionmanager.components.{
RuntimeVersionManagementUserInterface,
RuntimeVersionManager
Expand Down Expand Up @@ -32,11 +32,18 @@ import org.enso.runtimeversionmanager.test.{

import scala.util.{Failure, Success, Try}

/** A distribution configuration for use in tests.
*
* @param distributionRoot root of the test distribution, should be located
* within some temporary directory
* @param engineReleaseProvider provider of (fake) engine releases
* @param runtimeReleaseProvider provider of (fake) Graal releases
*/
class TestDistributionConfiguration(
distributionRoot: Path,
override val engineReleaseProvider: ReleaseProvider[EngineRelease],
runtimeReleaseProvider: GraalVMRuntimeReleaseProvider
) extends DistributionManagementConfiguration
) extends DistributionConfiguration
with FakeEnvironment {

def getTestDirectory: Path = distributionRoot
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ sealed class ComponentsException(
cause: Throwable = null
) extends RuntimeException(message, cause) {

/** @inheritdoc
*/
/** @inheritdoc */
override def toString: String = {
val causeMessage = if (cause != null) s" (Caused by: $cause)" else ""
message + causeMessage
Expand All @@ -21,8 +20,7 @@ sealed class ComponentsException(
case class InstallationError(message: String, cause: Throwable = null)
extends ComponentsException(message, cause) {

/** @inheritdoc
*/
/** @inheritdoc */
override def toString: String = s"Installation failed: $message"
}

Expand All @@ -32,8 +30,7 @@ case class InstallationError(message: String, cause: Throwable = null)
case class BrokenComponentError(message: String, cause: Throwable = null)
extends ComponentsException(message, cause) {

/** @inheritdoc
*/
/** @inheritdoc */
override def toString: String =
s"Installation was cancelled as the component to install was marked as " +
s"broken."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,15 +194,3 @@ class ResourceManager(lockManager: LockManager) {
"distribution. Please wait until that finishes."
}
}

object ResourceManager {
object WarnWhenWaiting extends LockUserInterface {

/** @inheritdoc */
override def startWaitingForResource(resource: Resource): Unit =
Logger[WarnWhenWaiting.type].warn(resource.waitMessage)

/** @inheritdoc */
override def finishWaitingForResource(resource: Resource): Unit = ()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package org.enso.runtimeversionmanager.releases.engine
import org.enso.runtimeversionmanager.releases.ReleaseProvider
import org.enso.runtimeversionmanager.releases.github.GithubReleaseProvider

/** Represents the default Enso repository providing releases for the engine. */
/** Represents the default Enso repository providing releases of the engine. */
object EngineRepository {
// TODO [RW] The release provider will be moved from staging to the main
// repository, when the first official Enso release is released.
Expand Down