refactor(server,cli): shared payload-discriminator helper, single-read digest reuse, DOT label escaping
This commit is contained in:
@@ -44,14 +44,16 @@ fun renderEventRows(rows: List<EventRow>): String {
|
||||
return (listOf(header) + lines).joinToString("\n")
|
||||
}
|
||||
|
||||
private fun String.dotEscape(): String = replace("\\", "\\\\").replace("\"", "\\\"")
|
||||
|
||||
fun renderDot(rows: List<EventRow>): String = buildString {
|
||||
appendLine("digraph session {")
|
||||
rows.forEach { r ->
|
||||
appendLine(""""${r.eventId}" [label="${r.type} #${r.sequence}"]""")
|
||||
appendLine(""""${r.eventId.dotEscape()}" [label="${r.type.dotEscape()} #${r.sequence}"]""")
|
||||
}
|
||||
rows.forEach { r ->
|
||||
r.causationId?.let { causation ->
|
||||
appendLine(""""${r.eventId}" -> "$causation"""")
|
||||
appendLine(""""${r.eventId.dotEscape()}" -> "${causation.dotEscape()}"""")
|
||||
}
|
||||
}
|
||||
append("}")
|
||||
|
||||
Reference in New Issue
Block a user