Concurrency limited merge

69 views
Skip to first unread message

Juan Pablo Marín

unread,
May 6, 2021, 5:13:43 PM5/6/21
to SmallRye
Hi! I've been a Reactor user for some time and now I'm doing some experiments with Mutiny, on reactor there is a flatmap argument that you can use to limit how many subscriptions will be created concurrently, it's like a concat but with multiple subscriptions running concurrently instead of just one. https://projectreactor.io/docs/core/release/api/reactor/core/publisher/Flux.html#flatMap-java.util.function.Function-int-

Is there a way to implement this with mutiny?

clement escoffier

unread,
May 7, 2021, 2:13:29 AM5/7/21
to SmallRye
Yes, the concurrency level on a merge can be configured using the `multi.onItem().transformToUni(...).merge(concurrency)`:

        List<Integer> list = multi
                .onItem().transformToUni(i -> Uni.createFrom().item(i)
                        .onItem().delayIt().by(Duration.of(random.nextInt(100) + 1, ChronoUnit.MILLIS))).merge(10)
                .collect().asList().await().indefinitely();

It also works with transformToMulti.

Clement

Le jeu. 6 mai 2021 à 23:13, Juan Pablo Marín <juanpabl...@gmail.com> a écrit :
Hi! I've been a Reactor user for some time and now I'm doing some experiments with Mutiny, on reactor there is a flatmap argument that you can use to limit how many subscriptions will be created concurrently, it's like a concat but with multiple subscriptions running concurrently instead of just one. https://projectreactor.io/docs/core/release/api/reactor/core/publisher/Flux.html#flatMap-java.util.function.Function-int-

Is there a way to implement this with mutiny?

--
You received this message because you are subscribed to the Google Groups "SmallRye" group.
To unsubscribe from this group and stop receiving emails from it, send an email to smallrye+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/smallrye/dac179fa-7def-4c8b-92ba-3bd30fe9a0cfn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages