Open andrus opened 5 years ago
The simplest approach would be to redo RelatedDataResolver.onParentDataResolved
method to take a CompletionStage<Iterable>
for parent data:
void onParentDataResolved(
RelatedResourceEntity<T> entity,
CompletionStage<Iterable<?>> parentData,
SelectContext<?> context);
In this case maybe we won't even need RelatedDataResolver.onParentQueryAssembled
, simplifying the design. With this API the child can decide whether to do something after the parent is resolved, or do something right away in parallel.
TODO: need a benchmark to estimate the cost of wrapping everything in ComletionStage
.
Now that we have a universal and flexible resolver lifecycle (#413), let's figure out how to build resolvers working in parallel. Each resolver knows whether it needs to wait for the parent to complete before firing up, so I think we can create a simple framework that can allow arbitrary resolvers to decide whether they are sequential or parallel and execute accordingly. E.g.
ViaQueryWithParentQualifierResolver
(the default nested resolver) can totally work in parallel.