WIP
authorKai Moritz <kai@juplo.de>
Fri, 24 Feb 2023 10:17:27 +0000 (11:17 +0100)
committerKai Moritz <kai@juplo.de>
Fri, 24 Feb 2023 10:17:27 +0000 (11:17 +0100)
src/main/java/de/juplo/kafka/chat/backend/api/ChatBackendController.java
src/main/java/de/juplo/kafka/chat/backend/domain/ChatHomeService.java
src/main/java/de/juplo/kafka/chat/backend/persistence/inmemory/InMemoryChatHomeService.java

index b17050a..482e1f9 100644 (file)
@@ -42,15 +42,6 @@ public class ChatBackendController
         .map(chatroom -> ChatRoomInfoTo.from(chatroom));
   }
 
-  @GetMapping("list")
-  public Mono<ChatRoomsTo> list()
-  {
-    return Arrays
-        .stream(ownedShards)
-        .mapToObj(shard -> chatHome.getChatRooms(shard))
-        .map(chatroom -> ChatRoomInfoTo.from(chatroom));
-  }
-
   @GetMapping("{chatroomId}/list")
   public Flux<MessageTo> list(@PathVariable UUID chatroomId)
   {
index fc5ba38..7876130 100644 (file)
@@ -9,5 +9,5 @@ import java.util.UUID;
 public interface ChatHomeService
 {
   Mono<ChatRoom> getChatRoom(UUID id);
-  Flux<ChatRoom> getChatRooms(int shard);
+  Flux<ChatRoom> getChatRooms();
 }
index 5e1f7dc..a72b0c9 100644 (file)
@@ -91,8 +91,10 @@ public class InMemoryChatHomeService implements ChatHomeService
   }
 
   @Override
-  public Flux<ChatRoom> getChatRooms(int shard)
+  public Flux<ChatRoom> getChatRooms()
   {
-    return Flux.fromStream(chatrooms[shard].values().stream());
+    return Flux
+        .fromIterable(ownedShards)
+        .flatMap(shard -> chatrooms[shard].values().stream());
   }
 }