[events-processors] change where topo description is written

This commit is contained in:
Adam 2022-10-22 19:52:02 +02:00
parent 657d5712f6
commit ce0d4b7378
2 changed files with 19 additions and 15 deletions

View file

@ -35,7 +35,7 @@ data class ApplicationProperties(
.addEnvironmentSource() .addEnvironmentSource()
.addResourceOrFileSource( .addResourceOrFileSource(
resourceOrFile = "${System.getProperty("user.home")}/.secret.kafkatorio-config.yml", resourceOrFile = "${System.getProperty("user.home")}/.secret.kafkatorio-config.yml",
optional = true optional = true,
) )
.addResourceOrFileSource("/.secret.config.yml", optional = true) .addResourceOrFileSource("/.secret.config.yml", optional = true)
.addResourceOrFileSource("/config.yml", optional = false) .addResourceOrFileSource("/config.yml", optional = false)

View file

@ -4,7 +4,6 @@ import dev.adamko.kafkatorio.processor.config.ApplicationProperties
import java.util.Properties import java.util.Properties
import kotlin.coroutines.resume import kotlin.coroutines.resume
import kotlin.coroutines.resumeWithException import kotlin.coroutines.resumeWithException
import kotlin.io.path.Path
import kotlinx.coroutines.CoroutineName import kotlinx.coroutines.CoroutineName
import kotlinx.coroutines.cancel import kotlinx.coroutines.cancel
import kotlinx.coroutines.coroutineScope import kotlinx.coroutines.coroutineScope
@ -18,7 +17,6 @@ import org.apache.kafka.streams.Topology
import org.apache.kafka.streams.TopologyDescription import org.apache.kafka.streams.TopologyDescription
suspend fun launchTopology( suspend fun launchTopology(
id: String, id: String,
topology: Topology, topology: Topology,
@ -58,7 +56,7 @@ suspend fun launchTopology(
streams.close() streams.close()
} }
printTopologyDescription(appId, topology) printTopologyDescription(appId, topology, appProps)
streams.start() streams.start()
println("launched Topology $appId") println("launched Topology $appId")
} }
@ -68,10 +66,16 @@ suspend fun launchTopology(
} }
private fun printTopologyDescription(appId: String, topology: Topology) { private fun printTopologyDescription(
appId: String,
topology: Topology,
appProps: ApplicationProperties,
) {
val description: TopologyDescription = topology.describe() val description: TopologyDescription = topology.describe()
val descFile = Path("./build/$appId.txt").toFile().apply { val descFile = appProps.serverDataDir
.resolve("kafka-streams/$appId.txt")
.toFile().apply {
parentFile.mkdirs() parentFile.mkdirs()
if (!exists()) createNewFile() if (!exists()) createNewFile()
writeText(description.toString()) writeText(description.toString())