event-server tidy up (improve value class, rm unused class, rename websocket broadcaster)

This commit is contained in:
Adam 2022-06-27 22:08:39 +02:00
parent e9a4ee4c48
commit fc758030fd
4 changed files with 6 additions and 5 deletions

View file

@ -187,7 +187,7 @@ private fun KTable<ServerMapChunkId, ServerMapChunkTiles<TileProtoHashCode>>.enr
val missingProtos = mutableSetOf<TileProtoHashCode>() val missingProtos = mutableSetOf<TileProtoHashCode>()
val tileColours = tiles.map.mapValues { (_, code) -> val tileColours = tiles.map.mapValues { (_, code) ->
colourDict.map.getOrElse(code) { colourDict.getOrElse(code) {
missingProtos.add(code) missingProtos.add(code)
ColourHex.TRANSPARENT ColourHex.TRANSPARENT
} }

View file

@ -1 +0,0 @@
package dev.adamko.kafkatorio.processor.topology

View file

@ -29,7 +29,9 @@ value class TileProtoHashCode private constructor(val code: Int) {
@JvmInline @JvmInline
@Serializable @Serializable
value class TileColourDict(val map: Map<TileProtoHashCode, ColourHex>) value class TileColourDict(
private val map: Map<TileProtoHashCode, ColourHex>
) : Map<TileProtoHashCode, ColourHex> by map
/** Get the latest map-tile colours per server. */ /** Get the latest map-tile colours per server. */
@ -48,9 +50,9 @@ fun KStream<FactorioServerId, PrototypesUpdate>.createTilePrototypeTable()
TileColourDict(map) TileColourDict(map)
}.filter("$pid.filterMapTileProtos") { _, dict: TileColourDict -> }.filter("$pid.filterMapTileProtos") { _, dict: TileColourDict ->
dict.map.isNotEmpty() dict.isNotEmpty()
}.peek { serverId, dict: TileColourDict -> }.peek { serverId, dict: TileColourDict ->
println("$pid: server $serverId has TileColourDict[${dict.map.size}]: ${dict.map.entries.joinToString()}") println("$pid: server $serverId has TileColourDict[${dict.size}]: ${dict.entries.joinToString()}")
}.repartition( }.repartition(
repartitionedAs( repartitionedAs(
"$pid.pre-table-repartition", "$pid.pre-table-repartition",