[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()
.addResourceOrFileSource(
resourceOrFile = "${System.getProperty("user.home")}/.secret.kafkatorio-config.yml",
optional = true
optional = true,
)
.addResourceOrFileSource("/.secret.config.yml", optional = true)
.addResourceOrFileSource("/config.yml", optional = false)

View file

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