summaryrefslogtreecommitdiffstats
path: root/sources/hv-collector-configuration/src
diff options
context:
space:
mode:
authorFilip Krzywka <filip.krzywka@nokia.com>2019-03-26 13:57:11 +0100
committerFilip Krzywka <filip.krzywka@nokia.com>2019-03-27 12:44:17 +0100
commitd6e646205cf290f46e980ad2470225c7d0b42618 (patch)
tree0f441ca56396dcb3fb455b849f5ddd8f421167a2 /sources/hv-collector-configuration/src
parent2b748ea515290984c5657e4d4a1027ff2e90bd61 (diff)
Move routing functionality inside Router
- also removed Routing-DSL as it won't be needed anymore Change-Id: Ifc7bc7641a60936b5257c0bff7a8c51dddc30687 Issue-ID: DCAEGEN2-1347 Signed-off-by: Filip Krzywka <filip.krzywka@nokia.com>
Diffstat (limited to 'sources/hv-collector-configuration/src')
-rw-r--r--sources/hv-collector-configuration/src/main/kotlin/org/onap/dcae/collectors/veshv/config/api/model/Routing.kt55
1 files changed, 2 insertions, 53 deletions
diff --git a/sources/hv-collector-configuration/src/main/kotlin/org/onap/dcae/collectors/veshv/config/api/model/Routing.kt b/sources/hv-collector-configuration/src/main/kotlin/org/onap/dcae/collectors/veshv/config/api/model/Routing.kt
index aab8ecad..45180a84 100644
--- a/sources/hv-collector-configuration/src/main/kotlin/org/onap/dcae/collectors/veshv/config/api/model/Routing.kt
+++ b/sources/hv-collector-configuration/src/main/kotlin/org/onap/dcae/collectors/veshv/config/api/model/Routing.kt
@@ -19,59 +19,8 @@
*/
package org.onap.dcae.collectors.veshv.config.api.model
-import arrow.core.Option
-import org.onap.dcae.collectors.veshv.domain.RoutedMessage
-import org.onap.dcae.collectors.veshv.domain.VesMessage
import org.onap.ves.VesEventOuterClass.CommonEventHeader
-data class Routing(val routes: List<Route>) {
+data class Routing(val routes: List<Route>)
- fun routeFor(commonHeader: CommonEventHeader): Option<Route> =
- Option.fromNullable(routes.find { it.applies(commonHeader) })
-}
-
-data class Route(val domain: String, val targetTopic: String, val partitioning: (CommonEventHeader) -> Int = { 0 }) {
-
- fun applies(commonHeader: CommonEventHeader) = commonHeader.domain == domain
-
- operator fun invoke(message: VesMessage): RoutedMessage =
- RoutedMessage(targetTopic, partitioning(message.header), message)
-}
-
-
-/*
-HvVesConfiguration DSL
-*/
-
-fun routing(init: RoutingBuilder.() -> Unit): RoutingBuilder = RoutingBuilder().apply(init)
-
-class RoutingBuilder {
- private val routes: MutableList<RouteBuilder> = mutableListOf()
-
- fun defineRoute(init: RouteBuilder.() -> Unit): RouteBuilder = RouteBuilder()
- .apply(init)
- .also { routes.add(it) }
-
- fun build() = Routing(routes.map { it.build() }.toList())
-}
-
-class RouteBuilder {
-
- private lateinit var domain: String
- private lateinit var targetTopic: String
- private lateinit var partitioning: (CommonEventHeader) -> Int
-
- fun fromDomain(domain: String): RouteBuilder = apply {
- this.domain = domain
- }
-
- fun toTopic(targetTopic: String): RouteBuilder = apply {
- this.targetTopic = targetTopic
- }
-
- fun withFixedPartitioning(num: Int = 0): RouteBuilder = apply {
- partitioning = { num }
- }
-
- fun build() = Route(domain, targetTopic, partitioning)
-}
+data class Route(val domain: String, val targetTopic: String, val partitioning: (CommonEventHeader) -> Int = { 0 }) \ No newline at end of file