From 3449b38b23fe1952a534ab35c5a23105c13e8262 Mon Sep 17 00:00:00 2001 From: Filip Krzywka Date: Mon, 17 Jun 2019 13:52:06 +0200 Subject: Fix request interval In previous implementation DistinctUntilChangedSubscriber always requested from upstream 256 events, which resulted in immediate 256 requests to CBS. Request amount is not configurable in other way than hard-limiting using `limitRequest`, which limits request amount for single subscriber. (At least in our pipeline) To avoid multiple manual subscribes, this commit changed CbsClientAdapter to use Mono instead of Flux for CbsRequests and repeat this Mono conditionally. Flux inside of repeatWhen is emitting event after each onComplete received from upstream Mono and resubscribes to it if condition is met. This seemed like good place to put our interval mechanism, which is always-pass condition, but condition resolving blocks for variable duration. Change-Id: I04d1e657ec4d82185f6f07422c25c2d2ff23e60d Issue-ID: DCAEGEN2-1557 Signed-off-by: Filip Krzywka --- .../src/main/kotlin/org/onap/dcae/collectors/veshv/utils/rx/rx.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'sources/hv-collector-utils/src/main/kotlin/org/onap') diff --git a/sources/hv-collector-utils/src/main/kotlin/org/onap/dcae/collectors/veshv/utils/rx/rx.kt b/sources/hv-collector-utils/src/main/kotlin/org/onap/dcae/collectors/veshv/utils/rx/rx.kt index e1886055..d68ca5c1 100644 --- a/sources/hv-collector-utils/src/main/kotlin/org/onap/dcae/collectors/veshv/utils/rx/rx.kt +++ b/sources/hv-collector-utils/src/main/kotlin/org/onap/dcae/collectors/veshv/utils/rx/rx.kt @@ -34,6 +34,6 @@ import java.time.Duration fun Publisher.then(callback: () -> Unit): Mono = toMono().then(Mono.fromCallable(callback)) -fun delayElements(intervalSupplier: () -> Duration): (Flux) -> Flux = { flux -> - flux.concatMap { Mono.just(it).delayElement(intervalSupplier()) } -} +fun Flux.nextWithVariableInterval(intervalSupplier: () -> Duration): Flux = + concatMap { Mono.just(it).delayElement(intervalSupplier()) } + -- cgit 1.2.3-korg