From 9c07a0e6c4691f762e30b0549f39219b9aa3bcb9 Mon Sep 17 00:00:00 2001 From: Rodolfo Date: Fri, 10 Jan 2025 14:32:42 -0300 Subject: [PATCH] renamed to ViewProjector --- src/main/kotlin/crablet/query/CrabletQueryApi.kt | 4 ++-- src/main/kotlin/crablet/query/impl/SubscriptionComponent.kt | 2 +- src/test/kotlin/crablet/query/AccountsViewProjectionTest.kt | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/kotlin/crablet/query/CrabletQueryApi.kt b/src/main/kotlin/crablet/query/CrabletQueryApi.kt index bd6ca8e..b975073 100644 --- a/src/main/kotlin/crablet/query/CrabletQueryApi.kt +++ b/src/main/kotlin/crablet/query/CrabletQueryApi.kt @@ -11,7 +11,7 @@ data class SubscriptionSource( val maxNumberOfRowsToPull: Int = 250, ) -interface EventViewProjector { +interface ViewProjector { fun project( sqlConnection: SqlConnection, eventAsJson: JsonObject, @@ -20,7 +20,7 @@ interface EventViewProjector { class SubscriptionConfig( val source: SubscriptionSource, - val eventViewProjector: EventViewProjector, + val viewProjector: ViewProjector, val callback: (() -> Unit)? = null, ) diff --git a/src/main/kotlin/crablet/query/impl/SubscriptionComponent.kt b/src/main/kotlin/crablet/query/impl/SubscriptionComponent.kt index 5765f60..68977a0 100644 --- a/src/main/kotlin/crablet/query/impl/SubscriptionComponent.kt +++ b/src/main/kotlin/crablet/query/impl/SubscriptionComponent.kt @@ -30,7 +30,7 @@ class SubscriptionComponent( }.flatMap { jsonList: List -> jsonList .fold(Future.succeededFuture()) { future, eventJson -> - future.compose { subscriptionConfig.eventViewProjector.project(tx, eventJson) } + future.compose { subscriptionConfig.viewProjector.project(tx, eventJson) } }.map { jsonList } }.compose { jsonList: List -> if (jsonList.isNotEmpty()) { diff --git a/src/test/kotlin/crablet/query/AccountsViewProjectionTest.kt b/src/test/kotlin/crablet/query/AccountsViewProjectionTest.kt index 6dd1b8c..79eb840 100644 --- a/src/test/kotlin/crablet/query/AccountsViewProjectionTest.kt +++ b/src/test/kotlin/crablet/query/AccountsViewProjectionTest.kt @@ -193,7 +193,7 @@ class AccountsViewProjectionTest : AbstractCrabletTest() { val source = SubscriptionSource(name = "accounts-view", eventTypes = eventTypes) - class AccountsViewProjector : EventViewProjector { + class AccountsViewProjector : ViewProjector { override fun project(sqlConnection: SqlConnection, eventAsJson: JsonObject): Future { val eventPayload = eventAsJson.getJsonObject("event_payload") @@ -231,7 +231,7 @@ class AccountsViewProjectionTest : AbstractCrabletTest() { val subscriptionConfig = SubscriptionConfig( source = source, - eventViewProjector = AccountsViewProjector(), + viewProjector = AccountsViewProjector(), callback = { latch.countDown() }) container.addSubscription( subscriptionConfig = subscriptionConfig,