(qs) Parallel execution
This commit is contained in:
parent
efb73ff4e7
commit
731afcb864
@ -8,6 +8,7 @@ import io.reactivex.rxjava3.core.Observable;
|
|||||||
import io.reactivex.rxjava3.schedulers.Schedulers;
|
import io.reactivex.rxjava3.schedulers.Schedulers;
|
||||||
import nu.marginalia.client.AbstractDynamicClient;
|
import nu.marginalia.client.AbstractDynamicClient;
|
||||||
import nu.marginalia.client.Context;
|
import nu.marginalia.client.Context;
|
||||||
|
import nu.marginalia.client.exception.RouteNotConfiguredException;
|
||||||
import nu.marginalia.index.client.model.query.SearchSpecification;
|
import nu.marginalia.index.client.model.query.SearchSpecification;
|
||||||
import nu.marginalia.index.client.model.results.SearchResultSet;
|
import nu.marginalia.index.client.model.results.SearchResultSet;
|
||||||
import nu.marginalia.model.gson.GsonFactory;
|
import nu.marginalia.model.gson.GsonFactory;
|
||||||
@ -56,12 +57,15 @@ public class IndexClient extends AbstractDynamicClient {
|
|||||||
@CheckReturnValue
|
@CheckReturnValue
|
||||||
public SearchResultSet query(Context ctx, List<Integer> nodes, SearchSpecification specs) {
|
public SearchResultSet query(Context ctx, List<Integer> nodes, SearchSpecification specs) {
|
||||||
return Observable.fromIterable(nodes)
|
return Observable.fromIterable(nodes)
|
||||||
.concatMap(node -> this
|
.flatMap(node -> {
|
||||||
.postGet(ctx, node,"/search/", specs, SearchResultSet.class)
|
try {
|
||||||
.onErrorReturn(t -> new SearchResultSet()),
|
return this
|
||||||
nodes.size(),
|
.postGet(ctx, node, "/search/", specs, SearchResultSet.class).onErrorReturn(t -> new SearchResultSet())
|
||||||
Schedulers.io()
|
.observeOn(Schedulers.io());
|
||||||
)
|
} catch (RouteNotConfiguredException ex) {
|
||||||
|
return Observable.error(ex);
|
||||||
|
}
|
||||||
|
})
|
||||||
.reduce(SearchResultSet::combine)
|
.reduce(SearchResultSet::combine)
|
||||||
.blockingGet();
|
.blockingGet();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user