diff --git a/dataforge-distributed/src/jvmMain/kotlin/space/kscience/dataforge/distributed/ServiceWorkspace.kt b/dataforge-distributed/src/jvmMain/kotlin/space/kscience/dataforge/distributed/ServiceWorkspace.kt index 3eecfd7c..cf17ce04 100644 --- a/dataforge-distributed/src/jvmMain/kotlin/space/kscience/dataforge/distributed/ServiceWorkspace.kt +++ b/dataforge-distributed/src/jvmMain/kotlin/space/kscience/dataforge/distributed/ServiceWorkspace.kt @@ -1,6 +1,7 @@ package space.kscience.dataforge.distributed import io.ktor.utils.io.core.* +import io.lambdarpc.coding.coders.JsonCoder import io.lambdarpc.dsl.LibService import io.lambdarpc.dsl.def import io.lambdarpc.dsl.j @@ -13,10 +14,8 @@ import space.kscience.dataforge.context.gather import space.kscience.dataforge.data.DataSet import space.kscience.dataforge.data.DataTree import space.kscience.dataforge.distributed.serialization.DataSetPrototype -import space.kscience.dataforge.distributed.serialization.MetaCoder -import space.kscience.dataforge.distributed.serialization.NameCoder -import space.kscience.dataforge.distributed.serialization.TaskRegistryCoder import space.kscience.dataforge.meta.Meta +import space.kscience.dataforge.meta.MetaSerializer import space.kscience.dataforge.names.Name import space.kscience.dataforge.names.asName import space.kscience.dataforge.workspace.SerializableResultTask @@ -114,6 +113,9 @@ public class ServiceWorkspace( public companion object { internal val serviceId = ServiceId("d41b95b1-828b-4444-8ff0-6f9c92a79246") - internal val execute by serviceId.def(NameCoder, MetaCoder, TaskRegistryCoder, j()) + internal val execute by serviceId.def( + JsonCoder(Name.serializer()), JsonCoder(MetaSerializer), j(), + j() + ) } } diff --git a/dataforge-distributed/src/jvmMain/kotlin/space/kscience/dataforge/distributed/serialization/MetaCoder.kt b/dataforge-distributed/src/jvmMain/kotlin/space/kscience/dataforge/distributed/serialization/MetaCoder.kt deleted file mode 100644 index d5425271..00000000 --- a/dataforge-distributed/src/jvmMain/kotlin/space/kscience/dataforge/distributed/serialization/MetaCoder.kt +++ /dev/null @@ -1,23 +0,0 @@ -package space.kscience.dataforge.distributed.serialization - -import io.lambdarpc.coding.Coder -import io.lambdarpc.coding.CodingContext -import io.lambdarpc.transport.grpc.Entity -import io.lambdarpc.transport.serialization.Entity -import io.lambdarpc.transport.serialization.RawData -import kotlinx.serialization.json.Json -import space.kscience.dataforge.meta.Meta -import space.kscience.dataforge.meta.MetaSerializer -import java.nio.charset.Charset - -internal object MetaCoder : Coder { - override suspend fun decode(entity: Entity, context: CodingContext): Meta { - val string = entity.data.toString(Charset.defaultCharset()) - return Json.decodeFromString(MetaSerializer, string) - } - - override suspend fun encode(value: Meta, context: CodingContext): Entity { - val string = Json.encodeToString(MetaSerializer, value) - return Entity(RawData.copyFrom(string, Charset.defaultCharset())) - } -} diff --git a/dataforge-distributed/src/jvmMain/kotlin/space/kscience/dataforge/distributed/serialization/NameCoder.kt b/dataforge-distributed/src/jvmMain/kotlin/space/kscience/dataforge/distributed/serialization/NameCoder.kt deleted file mode 100644 index 87d51901..00000000 --- a/dataforge-distributed/src/jvmMain/kotlin/space/kscience/dataforge/distributed/serialization/NameCoder.kt +++ /dev/null @@ -1,22 +0,0 @@ -package space.kscience.dataforge.distributed.serialization - -import io.lambdarpc.coding.Coder -import io.lambdarpc.coding.CodingContext -import io.lambdarpc.transport.grpc.Entity -import io.lambdarpc.transport.serialization.Entity -import io.lambdarpc.transport.serialization.RawData -import kotlinx.serialization.json.Json -import space.kscience.dataforge.names.Name -import java.nio.charset.Charset - -internal object NameCoder : Coder { - override suspend fun decode(entity: Entity, context: CodingContext): Name { - val string = entity.data.toString(Charset.defaultCharset()) - return Json.decodeFromString(Name.serializer(), string) - } - - override suspend fun encode(value: Name, context: CodingContext): Entity { - val string = Json.encodeToString(Name.serializer(), value) - return Entity(RawData.copyFrom(string, Charset.defaultCharset())) - } -} diff --git a/dataforge-distributed/src/jvmMain/kotlin/space/kscience/dataforge/distributed/serialization/TaskRegistryCoder.kt b/dataforge-distributed/src/jvmMain/kotlin/space/kscience/dataforge/distributed/serialization/TaskRegistryCoder.kt deleted file mode 100644 index 68c7e87f..00000000 --- a/dataforge-distributed/src/jvmMain/kotlin/space/kscience/dataforge/distributed/serialization/TaskRegistryCoder.kt +++ /dev/null @@ -1,22 +0,0 @@ -package space.kscience.dataforge.distributed.serialization - -import io.lambdarpc.coding.Coder -import io.lambdarpc.coding.CodingContext -import io.lambdarpc.transport.grpc.Entity -import io.lambdarpc.transport.serialization.Entity -import io.lambdarpc.transport.serialization.RawData -import kotlinx.serialization.json.Json -import space.kscience.dataforge.distributed.TaskRegistry -import java.nio.charset.Charset - -internal object TaskRegistryCoder : Coder { - override suspend fun decode(entity: Entity, context: CodingContext): TaskRegistry { - val string = entity.data.toString(Charset.defaultCharset()) - return Json.decodeFromString(TaskRegistry.serializer(), string) - } - - override suspend fun encode(value: TaskRegistry, context: CodingContext): Entity { - val string = Json.encodeToString(TaskRegistry.serializer(), value) - return Entity(RawData.copyFrom(string, Charset.defaultCharset())) - } -}