I'm using a messenger system. The stream follows publish the command-> read the command
@Serializable
data class Command <T> (
@Serializeble(KUUID::class) val id: UUID,
val status: CommandStatusEnum,
val message: T
)
enum class CommandStatusEnum(val value: String) {
Open("Open"),
Closed("Closed"),
Processing("Processing"),
Error("Error")
}
object KUUID : KSerializer<UUID> {
override val descriptor = PrimitiveSerialDescriptor("UUID", PrimitiveKind.STRING)
override fun serialize(encoder: Encoder, value: UUID) = encoder.encodeString(value.toString())
override fun deserialize(decoder: Decoder): UUID = UUID.fromString(decoder.decodeString())
}
the message can be any class, such as pro example, email class
@Serializable
data class EmailModel(
@Serializable(KUUID::class) override val id: UUID,
val active: Boolean,
val address: String,
@Serializable(KUUID::class) val associateFK: UUID
)