commonMain.it.unibo.pulvreakt.runtime.PulvreaktRuntime.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of runtime-jvm Show documentation
Show all versions of runtime-jvm Show documentation
A framework to create a pulverized system
package it.unibo.pulvreakt.runtime
import arrow.core.Either
import arrow.core.raise.either
import it.unibo.pulvreakt.api.infrastructure.Host
import it.unibo.pulvreakt.api.initializable.ManagedResource
import it.unibo.pulvreakt.dsl.model.PulvreaktConfiguration
import it.unibo.pulvreakt.runtime.errors.RuntimeError
/**
* The [PulvreaktRuntime] is the main entry point of the runtime.
*/
interface PulvreaktRuntime : ManagedResource {
/**
* Starts the runtime.
*/
suspend fun start(): Either
/**
* Stops the runtime.
*/
suspend fun stop(): Either
companion object {
/**
* Smart constructor for [PulvreaktRuntime].
* @return an [Either] with [RuntimeError] on the left side and [PulvreaktRuntime] on the right side.
*/
suspend operator fun invoke(
config: PulvreaktConfiguration,
device: String,
id: Int,
host: Host,
): Either = either {
val runtime = PulvreaktRuntimeImpl(config, device, id, host)
runtime.initialize().bind()
runtime
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy