From 2e7eefeba97b2728f058b5de40c05dbfe98c2213 Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Tue, 18 Jan 2022 18:39:19 +0300 Subject: [PATCH] rename methods --- .../ru/mipt/npm/controls/mongo/MongoEventStorage.kt | 4 ++-- .../ru/mipt/npm/controls/storage/EventStorage.kt | 12 ++++++------ .../ru/mipt/npm/controls/storage/storageCommon.kt | 2 +- .../ru/mipt/npm/controls/storage/storageJvm.kt | 2 +- .../ru/mipt/npm/controls/xodus/XodusEventStorage.kt | 4 ++-- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/controls-mongo/src/main/kotlin/ru/mipt/npm/controls/mongo/MongoEventStorage.kt b/controls-mongo/src/main/kotlin/ru/mipt/npm/controls/mongo/MongoEventStorage.kt index f6cb44f..4bfbafb 100644 --- a/controls-mongo/src/main/kotlin/ru/mipt/npm/controls/mongo/MongoEventStorage.kt +++ b/controls-mongo/src/main/kotlin/ru/mipt/npm/controls/mongo/MongoEventStorage.kt @@ -28,7 +28,7 @@ internal class MongoEventStorage( private val client: CoroutineClient, private val meta: Meta = Meta.EMPTY, ) : EventStorage { - override suspend fun storeValueInDeviceHub(value: T, serializer: KSerializer) { + override suspend fun storeDeviceMessage(value: T, serializer: KSerializer) { val collection = client .getDatabase( meta[MONGO_DEVICE_MESSAGE_DATABASE_NAME_PROPERTY]?.string @@ -39,7 +39,7 @@ internal class MongoEventStorage( collection.insertOne(Json.encodeToString(serializer, value)) } - override suspend fun storeValueInMagixServer(value: T, serializer: KSerializer) { + override suspend fun storeMagixMessage(value: T, serializer: KSerializer) { val collection = client .getDatabase(meta[MONGO_MAGIX_MESSAGE_DATABASE_NAME_PROPERTY]?.string ?: DEFAULT_MAGIX_MESSAGE_DATABASE_NAME) diff --git a/controls-storage/src/commonMain/kotlin/ru/mipt/npm/controls/storage/EventStorage.kt b/controls-storage/src/commonMain/kotlin/ru/mipt/npm/controls/storage/EventStorage.kt index 6f874aa..2388d05 100644 --- a/controls-storage/src/commonMain/kotlin/ru/mipt/npm/controls/storage/EventStorage.kt +++ b/controls-storage/src/commonMain/kotlin/ru/mipt/npm/controls/storage/EventStorage.kt @@ -6,15 +6,15 @@ import kotlinx.serialization.serializer import ru.mipt.npm.controls.api.PropertyChangedMessage public interface EventStorage : Closeable { - public suspend fun storeValueInDeviceHub(value: T, serializer: KSerializer) + public suspend fun storeDeviceMessage(value: T, serializer: KSerializer) - public suspend fun storeValueInMagixServer(value: T, serializer: KSerializer) + public suspend fun storeMagixMessage(value: T, serializer: KSerializer) public suspend fun getPropertyHistory(sourceDeviceName: String, propertyName: String): List } -public suspend inline fun EventStorage.storeValueInDeviceHub(value: T): Unit = - storeValueInDeviceHub(value, serializer()) +public suspend inline fun EventStorage.storeDeviceMessage(value: T): Unit = + storeDeviceMessage(value, serializer()) -public suspend inline fun EventStorage.storeValueInMagixServer(value: T): Unit = - storeValueInMagixServer(value, serializer()) +public suspend inline fun EventStorage.storeMagixMessage(value: T): Unit = + storeMagixMessage(value, serializer()) diff --git a/controls-storage/src/commonMain/kotlin/ru/mipt/npm/controls/storage/storageCommon.kt b/controls-storage/src/commonMain/kotlin/ru/mipt/npm/controls/storage/storageCommon.kt index 1446438..d035bc0 100644 --- a/controls-storage/src/commonMain/kotlin/ru/mipt/npm/controls/storage/storageCommon.kt +++ b/controls-storage/src/commonMain/kotlin/ru/mipt/npm/controls/storage/storageCommon.kt @@ -33,7 +33,7 @@ public fun DeviceManager.storeMessages( logger.debug { "Storage client created" } return hubMessageFlow(context).filter(filterCondition).onEach { message -> - client.storeValueInDeviceHub(message) + client.storeDeviceMessage(message) }.launchIn(context).apply { invokeOnCompletion(onCancelling = true) { client.close() diff --git a/controls-storage/src/jvmMain/kotlin/ru/mipt/npm/controls/storage/storageJvm.kt b/controls-storage/src/jvmMain/kotlin/ru/mipt/npm/controls/storage/storageJvm.kt index 4e068f3..cf09ceb 100644 --- a/controls-storage/src/jvmMain/kotlin/ru/mipt/npm/controls/storage/storageJvm.kt +++ b/controls-storage/src/jvmMain/kotlin/ru/mipt/npm/controls/storage/storageJvm.kt @@ -20,7 +20,7 @@ internal fun Flow.store( flowFilter: suspend (GenericMagixMessage) -> Boolean = { true }, ) { filter(flowFilter).onEach { message -> - client.storeValueInMagixServer(message) + client.storeMagixMessage(message) } } diff --git a/controls-xodus/src/main/kotlin/ru/mipt/npm/controls/xodus/XodusEventStorage.kt b/controls-xodus/src/main/kotlin/ru/mipt/npm/controls/xodus/XodusEventStorage.kt index 3072141..6e1e30a 100644 --- a/controls-xodus/src/main/kotlin/ru/mipt/npm/controls/xodus/XodusEventStorage.kt +++ b/controls-xodus/src/main/kotlin/ru/mipt/npm/controls/xodus/XodusEventStorage.kt @@ -22,11 +22,11 @@ private const val DEVICE_HUB_ENTITY_TYPE = "DeviceMessage" private const val MAGIX_SERVER_ENTITY_TYPE = "MagixMessage" public class XodusEventStorage(private val entityStore: PersistentEntityStore) : EventStorage { - override suspend fun storeValueInDeviceHub(value: T, serializer: KSerializer) { + override suspend fun storeDeviceMessage(value: T, serializer: KSerializer) { entityStore.encodeToEntity(value, DEVICE_HUB_ENTITY_TYPE, serializer) } - override suspend fun storeValueInMagixServer(value: T, serializer: KSerializer) { + override suspend fun storeMagixMessage(value: T, serializer: KSerializer) { entityStore.encodeToEntity(value, MAGIX_SERVER_ENTITY_TYPE, serializer) }