-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement API for sample management #1063
Implement API for sample management #1063
Conversation
asyncProjectService.getSamplePreviews(projectId.value(), experimentId.value(), | ||
query.getOffset(), query.getLimit(), List.copyOf(sortOrders), filter).collectList() | ||
.doOnError(RequestFailedException.class, this::handleRequestFailed) | ||
.block()).stream(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about https://projectreactor.io/docs/core/release/api/reactor/core/publisher/Flux.html#toStream-- instead?
Maybe you do not even need to block then (but I don't know this).
https://projectreactor.io/docs/core/release/reference/apdx-operatorChoice.html#which.blocking
Seems to me that a stream is returned (which is expected by vaadin) so the whole collection into a list and streaming afterwards might not be needed.
...c/main/java/life/qbic/datamanager/views/projects/project/samples/SampleDetailsComponent.java
Outdated
Show resolved
Hide resolved
.getValue(); | ||
var result = asyncProjectService | ||
.getSamples(context.projectId().orElseThrow().value(), experiment.experimentId().value()) | ||
.collectList().block(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of waiting for all elements to be there you could only wait for the first element as it is your concern whether the list is empty.
https://projectreactor.io/docs/core/release/reference/apdx-operatorChoice.html#which.blocking
https://projectreactor.io/docs/core/release/api/reactor/core/publisher/Flux.html#blockFirst-java.time.Duration-
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think that cheats the way Flux is working: we don't know how many samples will be send through the Flux. So maybe it is better to use a convenience method in the Service API instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why would this cheat the way flux is working?
The flux publishes elements and instead of waiting for the flux to complete, you can simply wait for the first element. No need for the flux to continue publishing afterwards as you do not want to use the result.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Of course you could think about adding a method Mono to determine whether there are any samples in an experiment. Depending on the way the flux is created this would minimize the work the system does. But I think both are legitimate ways to handle the situation. And both are better than to wait for the flux completion.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Provides the async service implementation for the sample management related requests.