chibenwa commented on code in PR #2917:
URL: https://github.com/apache/james-project/pull/2917#discussion_r2704367813
##########
server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/service/EventRetriever.java:
##########
@@ -69,7 +83,21 @@ public Optional<EventDeadLetters.InsertionId> forEvent() {
@Override
public Flux<Tuple3<Group, Event, EventDeadLetters.InsertionId>>
retrieveEvents(EventDeadLetters deadLetters) {
return deadLetters.groupsWithFailedEvents()
- .flatMap(group -> listGroupEvents(deadLetters, group),
DEFAULT_CONCURRENCY);
+ .collectList()
+ .flatMapMany(prioritizeCriticalGroups(deadLetters));
+ }
+
+ private Function<List<Group>, Publisher<Tuple3<Group, Event,
EventDeadLetters.InsertionId>>> prioritizeCriticalGroups(EventDeadLetters
deadLetters) {
+ return groups -> {
+ Map<Boolean, List<Group>> groupsByCriticality = groups.stream()
+ .collect(Collectors.partitioningBy(group ->
!this.nonCriticalGroups.contains(group)));
+
+ return Flux.concat(
+ Flux.fromIterable(groupsByCriticality.getOrDefault(true,
ImmutableList.of()))
+ .flatMap(group -> listGroupEvents(deadLetters, group),
DEFAULT_CONCURRENCY),
+ Flux.fromIterable(groupsByCriticality.getOrDefault(false,
ImmutableList.of()))
Review Comment:
True / false is a magic constant with no intrinsic meaning.
##########
server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/service/EventRetriever.java:
##########
@@ -69,7 +83,21 @@ public Optional<EventDeadLetters.InsertionId> forEvent() {
@Override
public Flux<Tuple3<Group, Event, EventDeadLetters.InsertionId>>
retrieveEvents(EventDeadLetters deadLetters) {
return deadLetters.groupsWithFailedEvents()
- .flatMap(group -> listGroupEvents(deadLetters, group),
DEFAULT_CONCURRENCY);
+ .collectList()
+ .flatMapMany(prioritizeCriticalGroups(deadLetters));
+ }
+
+ private Function<List<Group>, Publisher<Tuple3<Group, Event,
EventDeadLetters.InsertionId>>> prioritizeCriticalGroups(EventDeadLetters
deadLetters) {
+ return groups -> {
+ Map<Boolean, List<Group>> groupsByCriticality = groups.stream()
+ .collect(Collectors.partitioningBy(group ->
!this.nonCriticalGroups.contains(group)));
+
+ return Flux.concat(
Review Comment:
How about a sort? WOuldn't it be more natural and explicit?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]