diff --git a/controls-magix-client/src/commonMain/kotlin/space/kscience/controls/client/controlsMagix.kt b/controls-magix-client/src/commonMain/kotlin/space/kscience/controls/client/controlsMagix.kt index 00a1cc6..af223e3 100644 --- a/controls-magix-client/src/commonMain/kotlin/space/kscience/controls/client/controlsMagix.kt +++ b/controls-magix-client/src/commonMain/kotlin/space/kscience/controls/client/controlsMagix.kt @@ -42,7 +42,7 @@ public fun DeviceManager.connectToMagix( if (responsePayload != null) { endpoint.broadcast( format = controlsMagixFormat, - target = request.origin, + target = request.sourceEndpoint, origin = endpointID, payload = responsePayload, id = generateId(request), diff --git a/demo/echo/src/main/kotlin/space/kscience/controls/demo/echo/main.kt b/demo/echo/src/main/kotlin/space/kscience/controls/demo/echo/main.kt index f172b9a..881997b 100644 --- a/demo/echo/src/main/kotlin/space/kscience/controls/demo/echo/main.kt +++ b/demo/echo/src/main/kotlin/space/kscience/controls/demo/echo/main.kt @@ -44,8 +44,8 @@ private suspend fun MagixEndpoint.collectEcho(scope: CoroutineScope, n: Int) { MagixMessage( format = "test", payload = JsonObject(emptyMap()), - origin = "test", - target = "loop", + sourceEndpoint = "test", + targetEndpoint = "loop", id = it.toString() ) ) @@ -65,7 +65,7 @@ suspend fun main(): Unit = coroutineScope { //echo each message flow.onEach { message -> if (message.parentId == null) { - val m = message.copy(origin = "loop", parentId = message.id, id = message.id + ".response") + val m = message.copy(sourceEndpoint = "loop", parentId = message.id, id = message.id + ".response") logger.info(m.toString()) send(m) } diff --git a/demo/many-devices/src/main/kotlin/space/kscience/controls/demo/MassDevice.kt b/demo/many-devices/src/main/kotlin/space/kscience/controls/demo/MassDevice.kt index 5860211..5014a6f 100644 --- a/demo/many-devices/src/main/kotlin/space/kscience/controls/demo/MassDevice.kt +++ b/demo/many-devices/src/main/kotlin/space/kscience/controls/demo/MassDevice.kt @@ -97,7 +97,7 @@ fun main() { val latest = ConcurrentHashMap() monitorEndpoint.subscribe(DeviceManager.magixFormat).onEach { (magixMessage, payload) -> - latest[magixMessage.origin] = Clock.System.now() - payload.time!! + latest[magixMessage.sourceEndpoint] = Clock.System.now() - payload.time!! }.launchIn(this) while (isActive) { diff --git a/magix/magix-api/src/commonMain/kotlin/space/kscience/magix/api/MagixFormat.kt b/magix/magix-api/src/commonMain/kotlin/space/kscience/magix/api/MagixFormat.kt index 904afe6..c68e326 100644 --- a/magix/magix-api/src/commonMain/kotlin/space/kscience/magix/api/MagixFormat.kt +++ b/magix/magix-api/src/commonMain/kotlin/space/kscience/magix/api/MagixFormat.kt @@ -50,8 +50,8 @@ public suspend fun MagixEndpoint.broadcast( val message = MagixMessage( format = format.defaultFormat, payload = magixJson.encodeToJsonElement(format.serializer, payload), - origin = origin, - target = target, + sourceEndpoint = origin, + targetEndpoint = target, id = id, parentId = parentId, user = user diff --git a/magix/magix-api/src/commonMain/kotlin/space/kscience/magix/api/MagixMessage.kt b/magix/magix-api/src/commonMain/kotlin/space/kscience/magix/api/MagixMessage.kt index c25c08a..4162593 100644 --- a/magix/magix-api/src/commonMain/kotlin/space/kscience/magix/api/MagixMessage.kt +++ b/magix/magix-api/src/commonMain/kotlin/space/kscience/magix/api/MagixMessage.kt @@ -27,8 +27,8 @@ import kotlinx.serialization.json.JsonElement public data class MagixMessage( val format: String, val payload: JsonElement, - val origin: String, - val target: String? = null, + val sourceEndpoint: String, + val targetEndpoint: String? = null, val id: String? = null, val parentId: String? = null, val user: JsonElement? = null, diff --git a/magix/magix-api/src/commonMain/kotlin/space/kscience/magix/api/MagixMessageFilter.kt b/magix/magix-api/src/commonMain/kotlin/space/kscience/magix/api/MagixMessageFilter.kt index 10d4345..12def5b 100644 --- a/magix/magix-api/src/commonMain/kotlin/space/kscience/magix/api/MagixMessageFilter.kt +++ b/magix/magix-api/src/commonMain/kotlin/space/kscience/magix/api/MagixMessageFilter.kt @@ -16,8 +16,8 @@ public data class MagixMessageFilter( public fun accepts(message: MagixMessage): Boolean = format?.contains(message.format) ?: true - && origin?.contains(message.origin) ?: true - && target?.contains(message.target) ?: true + && origin?.contains(message.sourceEndpoint) ?: true + && target?.contains(message.targetEndpoint) ?: true public companion object { public val ALL: MagixMessageFilter = MagixMessageFilter() diff --git a/magix/magix-api/src/commonMain/kotlin/space/kscience/magix/api/converters.kt b/magix/magix-api/src/commonMain/kotlin/space/kscience/magix/api/converters.kt index 441e141..beed930 100644 --- a/magix/magix-api/src/commonMain/kotlin/space/kscience/magix/api/converters.kt +++ b/magix/magix-api/src/commonMain/kotlin/space/kscience/magix/api/converters.kt @@ -20,8 +20,8 @@ public fun CoroutineScope.launchMagixConverter( val transformed: MagixMessage = MagixMessage( outputFormat, newPayload, - newOrigin ?: message.origin, - message.target, + newOrigin ?: message.sourceEndpoint, + message.targetEndpoint, message.id, message.parentId, message.user diff --git a/magix/magix-mqtt/src/main/kotlin/space/ksceince/magix/mqtt/MqttMagixEndpoint.kt b/magix/magix-mqtt/src/main/kotlin/space/ksceince/magix/mqtt/MqttMagixEndpoint.kt index 296ddb0..ae41532 100644 --- a/magix/magix-mqtt/src/main/kotlin/space/ksceince/magix/mqtt/MqttMagixEndpoint.kt +++ b/magix/magix-mqtt/src/main/kotlin/space/ksceince/magix/mqtt/MqttMagixEndpoint.kt @@ -80,7 +80,7 @@ public class MqttMagixEndpoint( //TODO add target name escaping internal val defaultBroadcastTopicBuilder: (MagixMessage) -> String = { message -> - message.target?.let { "$DEFAULT_MAGIX_TOPIC_NAME/it" } ?: DEFAULT_MAGIX_TOPIC_NAME + message.targetEndpoint?.let { "$DEFAULT_MAGIX_TOPIC_NAME/it" } ?: DEFAULT_MAGIX_TOPIC_NAME } internal val defaultSubscribeTopicBuilder: (MagixMessageFilter) -> String = { filter -> diff --git a/magix/magix-storage/magix-storage-xodus/src/main/kotlin/space/kscience/magix/storage/xodus/XodusMagixStorage.kt b/magix/magix-storage/magix-storage-xodus/src/main/kotlin/space/kscience/magix/storage/xodus/XodusMagixStorage.kt index 1c9e636..7a8ead1 100644 --- a/magix/magix-storage/magix-storage-xodus/src/main/kotlin/space/kscience/magix/storage/xodus/XodusMagixStorage.kt +++ b/magix/magix-storage/magix-storage-xodus/src/main/kotlin/space/kscience/magix/storage/xodus/XodusMagixStorage.kt @@ -30,13 +30,13 @@ public class XodusMagixStorage( internal val subscriptionJob = endpoint.subscribe(filter).onEach { message -> store.executeInTransaction { transaction -> transaction.newEntity(MAGIC_MESSAGE_ENTITY_TYPE).apply { - setProperty(MagixMessage::origin.name, message.origin) + setProperty(MagixMessage::sourceEndpoint.name, message.sourceEndpoint) setProperty(MagixMessage::format.name, message.format) setBlobString(MagixMessage::payload.name, MagixEndpoint.magixJson.encodeToString(message.payload)) - message.target?.let { - setProperty(MagixMessage::target.name, it) + message.targetEndpoint?.let { + setProperty(MagixMessage::targetEndpoint.name, it) } message.id?.let { setProperty(MagixMessage::id.name, it) @@ -63,8 +63,8 @@ public class XodusMagixStorage( payload = getBlobString(MagixMessage::payload.name)?.let { magixJson.parseToJsonElement(it) } ?: JsonObject(emptyMap()), - origin = getProperty(MagixMessage::origin.name).toString(), - target = getProperty(MagixMessage::target.name)?.toString(), + sourceEndpoint = getProperty(MagixMessage::sourceEndpoint.name).toString(), + targetEndpoint = getProperty(MagixMessage::targetEndpoint.name)?.toString(), id = getProperty(MagixMessage::id.name)?.toString(), parentId = getProperty(MagixMessage::parentId.name)?.toString(), user = getBlobString(MagixMessage::user.name)?.let { @@ -129,10 +129,10 @@ public class XodusMagixStorage( transaction.findAllIn(MAGIC_MESSAGE_ENTITY_TYPE, MagixMessage::format.name, mf.format)?.let { res = res.intersect(it) } - transaction.findAllIn(MAGIC_MESSAGE_ENTITY_TYPE, MagixMessage::origin.name, mf.origin)?.let { + transaction.findAllIn(MAGIC_MESSAGE_ENTITY_TYPE, MagixMessage::sourceEndpoint.name, mf.origin)?.let { res = res.intersect(it) } - transaction.findAllIn(MAGIC_MESSAGE_ENTITY_TYPE, MagixMessage::target.name, mf.target)?.let { + transaction.findAllIn(MAGIC_MESSAGE_ENTITY_TYPE, MagixMessage::targetEndpoint.name, mf.target)?.let { res = res.intersect(it) } diff --git a/magix/magix-storage/src/commonMain/kotlin/space/kscience/magix/storage/historyEndpoint.kt b/magix/magix-storage/src/commonMain/kotlin/space/kscience/magix/storage/historyEndpoint.kt index cfee042..45a7f81 100644 --- a/magix/magix-storage/src/commonMain/kotlin/space/kscience/magix/storage/historyEndpoint.kt +++ b/magix/magix-storage/src/commonMain/kotlin/space/kscience/magix/storage/historyEndpoint.kt @@ -45,7 +45,7 @@ public fun MagixEndpoint.launchHistory( broadcast( format = MagixHistory.magixFormat, payload = sendPayload, - target = request.origin, + target = request.sourceEndpoint, id = generateId(request), parentId = request.id, user = user,