Merge pull request #7965 from macieg/bael-3285-3

BAEL-3285 | Removed block() calls
This commit is contained in:
Jonathan Cook 2019-10-11 13:27:42 +02:00 committed by GitHub
commit 8a973cf690
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 10 deletions

View File

@ -41,28 +41,25 @@ public class Client {
.bodyToMono(User.class); .bodyToMono(User.class);
} }
public List<User> fetchUsers(List<Integer> userIds) { public Flux<User> fetchUsers(List<Integer> userIds) {
return Flux.fromIterable(userIds) return Flux.fromIterable(userIds)
.parallel() .parallel()
.runOn(Schedulers.elastic()) .runOn(Schedulers.elastic())
.flatMap(this::getUser) .flatMap(this::getUser)
.collectSortedList((u1, u2) -> u2.id() - u1.id()) .ordered((u1, u2) -> u2.id() - u1.id());
.block();
} }
public List<User> fetchUserAndOtherUser(int id) { public Flux<User> fetchUserAndOtherUser(int id) {
return Flux.merge(getUser(id), getOtherUser(id)) return Flux.merge(getUser(id), getOtherUser(id))
.parallel() .parallel()
.runOn(Schedulers.elastic()) .runOn(Schedulers.elastic())
.collectSortedList((u1, u2) -> u2.id() - u1.id()) .ordered((u1, u2) -> u2.id() - u1.id());
.block();
} }
public UserWithItem fetchUserAndItem(int userId, int itemId) { public Mono<UserWithItem> fetchUserAndItem(int userId, int itemId) {
Mono<User> user = getUser(userId).subscribeOn(Schedulers.elastic()); Mono<User> user = getUser(userId).subscribeOn(Schedulers.elastic());
Mono<Item> item = getItem(itemId).subscribeOn(Schedulers.elastic()); Mono<Item> item = getItem(itemId).subscribeOn(Schedulers.elastic());
return Mono.zip(user, item, UserWithItem::new) return Mono.zip(user, item, UserWithItem::new);
.block();
} }
} }

View File

@ -56,7 +56,9 @@ public class ClientIntegrationTest {
// Act // Act
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
List<User> users = client.fetchUsers(userIds); List<User> users = client.fetchUsers(userIds)
.collectList()
.block();
long end = System.currentTimeMillis(); long end = System.currentTimeMillis();
// Assert // Assert