From e387caaa9253ba8cece94882d0a0b1f59277ce1a Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Fri, 24 Feb 2023 11:17:27 +0100 Subject: [PATCH] WIP --- .../kafka/chat/backend/api/ChatBackendController.java | 9 --------- .../juplo/kafka/chat/backend/domain/ChatHomeService.java | 2 +- .../persistence/inmemory/InMemoryChatHomeService.java | 6 ++++-- 3 files changed, 5 insertions(+), 12 deletions(-) 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()); } } -- 2.20.1