From dec45b60505ca9ba849ba18633fb69d55bf3b168 Mon Sep 17 00:00:00 2001 From: Atos1337 Date: Thu, 16 Dec 2021 16:54:48 +0300 Subject: [PATCH] Make this work --- build.gradle.kts | 2 +- .../main/kotlin/ru/mipt/npm/controls/xodus/connections.kt | 8 ++++---- .../ru/mipt/npm/controls/demo/car/VirtualCarController.kt | 5 ++--- gradle/wrapper/gradle-wrapper.properties | 2 +- settings.gradle.kts | 4 ++-- 5 files changed, 10 insertions(+), 11 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 9529d0d..6d7df71 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -2,7 +2,7 @@ plugins { id("ru.mipt.npm.gradle.project") } -val dataforgeVersion: String by extra("0.5.2") +val dataforgeVersion: String by extra("0.5.1") val ktorVersion: String by extra(ru.mipt.npm.gradle.KScienceVersions.ktorVersion) val rsocketVersion by extra("0.13.1") diff --git a/controls-xodus/src/main/kotlin/ru/mipt/npm/controls/xodus/connections.kt b/controls-xodus/src/main/kotlin/ru/mipt/npm/controls/xodus/connections.kt index 02d5805..8c72785 100644 --- a/controls-xodus/src/main/kotlin/ru/mipt/npm/controls/xodus/connections.kt +++ b/controls-xodus/src/main/kotlin/ru/mipt/npm/controls/xodus/connections.kt @@ -22,7 +22,7 @@ import space.kscience.dataforge.meta.string import space.kscience.dataforge.names.Name private const val DEFAULT_XODUS_STORE_PATH = ".storage" -private val XODUS_STORE_PROPERTY = Name.of("xodus", "entityStorePath") +public val XODUS_STORE_PROPERTY: Name = Name.of("xodus", "entityStorePath") private fun Context.getPersistentEntityStore(meta: Meta = Meta.EMPTY): PersistentEntityStore { val storePath = meta[XODUS_STORE_PROPERTY]?.string @@ -41,7 +41,7 @@ public fun DeviceManager.storeMessagesInXodus( factory: Factory = defaultPersistentStoreFactory, filterCondition: suspend (DeviceMessage) -> Boolean = { true }, ): Job { - val entityStore = factory(Meta.EMPTY, context) + val entityStore = factory(meta, context) logger.debug { "Device entity store opened" } return hubMessageFlow(context).filter(filterCondition).onEach { message -> @@ -76,7 +76,7 @@ public fun DeviceManager.storeMessagesInXodus( internal fun Flow.storeInXodus( entityStore: PersistentEntityStore, - flowFilter: (GenericMagixMessage) -> Boolean = { true }, + flowFilter: suspend (GenericMagixMessage) -> Boolean = { true }, ) { filter(flowFilter).onEach { message -> entityStore.encodeToEntity(message, "MagixMessage") @@ -88,7 +88,7 @@ public fun Application.storeInXodus( flow: MutableSharedFlow, meta: Meta = Meta.EMPTY, factory: Factory = defaultPersistentStoreFactory, - flowFilter: (GenericMagixMessage) -> Boolean = { true }, + flowFilter: suspend (GenericMagixMessage) -> Boolean = { true }, ) { val entityStore = factory(meta) diff --git a/demo/car/src/main/kotlin/ru/mipt/npm/controls/demo/car/VirtualCarController.kt b/demo/car/src/main/kotlin/ru/mipt/npm/controls/demo/car/VirtualCarController.kt index 5ab4372..03b62f1 100644 --- a/demo/car/src/main/kotlin/ru/mipt/npm/controls/demo/car/VirtualCarController.kt +++ b/demo/car/src/main/kotlin/ru/mipt/npm/controls/demo/car/VirtualCarController.kt @@ -15,6 +15,7 @@ import ru.mipt.npm.controls.controllers.install import ru.mipt.npm.controls.demo.car.IVirtualCar.Companion.acceleration import ru.mipt.npm.controls.mongo.MongoClientFactory import ru.mipt.npm.controls.mongo.connectMongo +import ru.mipt.npm.controls.xodus.XODUS_STORE_PROPERTY import ru.mipt.npm.controls.xodus.storeInXodus import ru.mipt.npm.controls.xodus.storeMessagesInXodus import ru.mipt.npm.magix.api.MagixEndpoint @@ -55,9 +56,7 @@ class VirtualCarController : Controller(), ContextAware { //starting magix event loop and connect it to entity store magixServer = startMagixServer(enableRawRSocket = true, enableZmq = true) { flow -> storeInXodus( flow, Meta { - "xodusConfig" put { - "entityStorePath" put VirtualCarControllerConfig.magixEntityStorePath.toString() - } + XODUS_STORE_PROPERTY put VirtualCarControllerConfig.magixEntityStorePath.toString() }) } magixVirtualCar = deviceManager.install("magix-virtual-car", MagixVirtualCar) diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index e750102..ffed3a2 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/settings.gradle.kts b/settings.gradle.kts index a1406e3..896d04d 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -5,7 +5,7 @@ enableFeaturePreview("VERSION_CATALOGS") pluginManagement { - val toolsVersion = "0.10.7" + val toolsVersion = "0.10.5" repositories { maven("https://repo.kotlin.link") @@ -29,7 +29,7 @@ dependencyResolutionManagement { versionCatalogs { create("npm") { - from("ru.mipt.npm:version-catalog:0.10.7") + from("ru.mipt.npm:version-catalog:0.10.5") } } }