I have a list of Rules that return Mono<Result>, I need to execute them and return another List of Mono with the result of each function.
Mono<List< Rule>> to Mono<List< RuleResult>>
I have this, which works but blocking the execution seems not correct to me:
List<Rule> RuleSet
...
Mono<List<RuleResult>> result= Mono.just(RuleSet.stream().map(rule -> rule.assess(object).block()).collect(Collectors.toList()));
How can I convert this into less blocking version?
I tried the following:
//Create a List of Monos
List<Mono<RuleResult>> ruleStream=statefulRuleSet.stream().map(rule -> rule.assess(assessmentObject)).collect(Collectors.toList());
//Cannot convert type
Flux.zip(ruleStream,...)).collectList();
//Not sure how to do this
Flux.fromIterable(ruleStream...).collectList();
Perhaps I am thinking of a wrong solution overall, somebody has any pointers?