Skip to content

Commit ccd59a5

Browse files
committed
revert singe serialization
1 parent 898f3d9 commit ccd59a5

File tree

1 file changed

+9
-19
lines changed

1 file changed

+9
-19
lines changed

envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/server/CachedProtoResourcesSerializer.kt

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ internal class CachedProtoResourcesSerializer(
2626
}
2727
}
2828

29-
private val cache: Cache<Collection<Message>, MutableCollection<Any>> = createCache("protobuf-cache")
29+
private val cache: Cache<Message, Any> = createCache("protobuf-cache")
3030
private val timer = createTimer(reportMetrics, meterRegistry, "protobuf-cache.serialize.time")
3131

3232
private fun <K, V> createCache(cacheName: String): Cache<K, V> {
@@ -47,23 +47,13 @@ internal class CachedProtoResourcesSerializer(
4747
}
4848
}
4949

50-
override fun serialize(
51-
resources: MutableCollection<out Message>,
52-
apiVersion: Resources.ApiVersion
53-
): MutableCollection<Any> {
54-
return timer.record(Supplier { getResources(resources) })
55-
}
56-
57-
private fun getResources(resources: MutableCollection<out Message>): MutableCollection<Any> {
58-
return cache.get(resources) {
59-
resources.asSequence()
60-
.map { Any.pack(it) }
61-
.toMutableList()
62-
}
63-
}
64-
65-
@Suppress("NotImplementedDeclaration")
66-
override fun serialize(resource: Message?, apiVersion: Resources.ApiVersion?): Any {
67-
throw NotImplementedError("Serializing single messages is not supported")
50+
override fun serialize(resource: Message, apiVersion: Resources.ApiVersion): Any {
51+
return timer.record(Supplier {
52+
cache.get(resource) {
53+
Any.pack(
54+
resource
55+
)
56+
}
57+
})
6858
}
6959
}

0 commit comments

Comments
 (0)