Convert Mono to Uni for Reactive Query Result to REST API

Hi,

I’m trying to develop REST API using quarkus that will expose reactive API.
In Quarkus, I saw reactive can be returned using Uni/Multi,

@GET
@Path(“/get/{name}”)
public Uni getName(@PathParam String name) {
return service.getName(name);
}

but in couchbase Java SDK,
I saw Reactive Query can be achived using Mono/ Flux.

Mono result = cluster.reactive().query(“select * from bucket use keys ‘xxx’”);

result .flatMapMany(ReactiveQueryResult::rowsAsObject)
.subscribe(row → System.out.println("Found row: " + row));

How to map from couchbase mono to uni that will return response from my REST API?

Thanks,

Hi @Han_Chris1

I’m not very familiar with Quarkus or the Mutiny library it’s using for these Uni/Multi, but this section of the docs looks relevant:


We use Project Reactor (Mono and Flux), and it’s usually easy and efficient to convert them into any library that implements the Reactive Streams specification (and it appears Mutiny does).