From: Kai Moritz Date: Fri, 24 Feb 2023 10:17:27 +0000 (+0100) Subject: WIP X-Git-Tag: wip-sharding~8 X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=e387caaa9253ba8cece94882d0a0b1f59277ce1a;p=demos%2Fkafka%2Fchat WIP --- diff --git a/src/main/java/de/juplo/kafka/chat/backend/api/ChatBackendController.java b/src/main/java/de/juplo/kafka/chat/backend/api/ChatBackendController.java index b17050ad..482e1f96 100644 --- a/src/main/java/de/juplo/kafka/chat/backend/api/ChatBackendController.java +++ b/src/main/java/de/juplo/kafka/chat/backend/api/ChatBackendController.java @@ -42,15 +42,6 @@ public class ChatBackendController .map(chatroom -> ChatRoomInfoTo.from(chatroom)); } - @GetMapping("list") - public Mono list() - { - return Arrays - .stream(ownedShards) - .mapToObj(shard -> chatHome.getChatRooms(shard)) - .map(chatroom -> ChatRoomInfoTo.from(chatroom)); - } - @GetMapping("{chatroomId}/list") public Flux list(@PathVariable UUID chatroomId) { diff --git a/src/main/java/de/juplo/kafka/chat/backend/domain/ChatHomeService.java b/src/main/java/de/juplo/kafka/chat/backend/domain/ChatHomeService.java index fc5ba384..7876130d 100644 --- a/src/main/java/de/juplo/kafka/chat/backend/domain/ChatHomeService.java +++ b/src/main/java/de/juplo/kafka/chat/backend/domain/ChatHomeService.java @@ -9,5 +9,5 @@ import java.util.UUID; public interface ChatHomeService { Mono getChatRoom(UUID id); - Flux getChatRooms(int shard); + Flux getChatRooms(); } diff --git a/src/main/java/de/juplo/kafka/chat/backend/persistence/inmemory/InMemoryChatHomeService.java b/src/main/java/de/juplo/kafka/chat/backend/persistence/inmemory/InMemoryChatHomeService.java index 5e1f7dc0..a72b0c92 100644 --- a/src/main/java/de/juplo/kafka/chat/backend/persistence/inmemory/InMemoryChatHomeService.java +++ b/src/main/java/de/juplo/kafka/chat/backend/persistence/inmemory/InMemoryChatHomeService.java @@ -91,8 +91,10 @@ public class InMemoryChatHomeService implements ChatHomeService } @Override - public Flux getChatRooms(int shard) + public Flux getChatRooms() { - return Flux.fromStream(chatrooms[shard].values().stream()); + return Flux + .fromIterable(ownedShards) + .flatMap(shard -> chatrooms[shard].values().stream()); } }