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);
}
public List<User> fetchUsers(List<Integer> userIds) {
public Flux<User> fetchUsers(List<Integer> userIds) {
return Flux.fromIterable(userIds)
.parallel()
.runOn(Schedulers.elastic())
.flatMap(this::getUser)
.collectSortedList((u1, u2) -> u2.id() - u1.id())
.block();
.ordered((u1, u2) -> u2.id() - u1.id());
}
public List<User> fetchUserAndOtherUser(int id) {
public Flux<User> fetchUserAndOtherUser(int id) {
return Flux.merge(getUser(id), getOtherUser(id))
.parallel()
.runOn(Schedulers.elastic())
.collectSortedList((u1, u2) -> u2.id() - u1.id())
.block();
.ordered((u1, u2) -> u2.id() - u1.id());
}
public UserWithItem fetchUserAndItem(int userId, int itemId) {
public Mono<UserWithItem> fetchUserAndItem(int userId, int itemId) {
Mono<User> user = getUser(userId).subscribeOn(Schedulers.elastic());
Mono<Item> item = getItem(itemId).subscribeOn(Schedulers.elastic());
return Mono.zip(user, item, UserWithItem::new)
.block();
return Mono.zip(user, item, UserWithItem::new);
}
}

View File

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