简体   繁体   中英

Mutiny - Discarding Failures when Combining Results of Several Unis

I'm using Mutiny to try to fetch data from several external sources. Each call produces a list of results, and I am currently combining these results into one list in a Uni as follows:

List<Uni<List<Result>>> unis = new ArrayList<>();
for (Source source : sources) {
    unis.add(source.getResults());
}

return Uni.combine().all().unis(unis).combinedWith(
        responses -> {
            List<Result> res = new ArrayList<>();
            for (List<Result> response : (List<List<Result>>) responses) {
                res.addAll(response);
            }
            return res;
        }
);

When one of these Unis fails, though, the entire final Uni fails.

I want to be able to get the combined list of results from all of the calls that do not fail, and just log failures or something, but I can't figure out how to do this from the Mutiny documentation. Any help would be much appreciated.

You should have an error-handling strategy for each Uni then, so the combination only sees succeeeding Uni .

See:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM