From b5f48159ddc241072d7b82d018741bcb8cc93b66 Mon Sep 17 00:00:00 2001 From: Rodolfo Date: Fri, 10 Jan 2025 22:46:37 -0300 Subject: [PATCH] using const successFuture --- src/main/kotlin/crablet/query/impl/SubscriptionComponent.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/crablet/query/impl/SubscriptionComponent.kt b/src/main/kotlin/crablet/query/impl/SubscriptionComponent.kt index bd06903..d925693 100644 --- a/src/main/kotlin/crablet/query/impl/SubscriptionComponent.kt +++ b/src/main/kotlin/crablet/query/impl/SubscriptionComponent.kt @@ -32,7 +32,7 @@ class SubscriptionComponent( when (val eventSync = subscriptionConfig.eventSink) { is EventSink.PostgresSingleEventSync -> { jsonList - .fold(Future.succeededFuture()) { future, eventJson -> + .fold(successFuture) { future, eventJson -> future.compose { eventSync.handle(tx, eventJson) } @@ -40,7 +40,7 @@ class SubscriptionComponent( } is EventSink.SingleEventSink -> { jsonList - .fold(Future.succeededFuture()) { future, eventJson -> + .fold(successFuture) { future, eventJson -> future.compose { eventSync.handle(eventJson) } @@ -67,6 +67,7 @@ class SubscriptionComponent( } companion object { + private val successFuture = Future.succeededFuture() private const val SQL_UPDATE_OFFSET = "UPDATE subscriptions SET sequence_id = $2 where name = $1" private const val SQL_EVENTS_QUERY = """ SELECT *