WIP
[demos/kafka/chat] / src / main / java / de / juplo / kafka / chat / backend / persistence / inmemory / SimpleChatHome.java
index 3048aa5..2987dd4 100644 (file)
@@ -13,13 +13,17 @@ import java.util.*;
 @Slf4j
 public class SimpleChatHome implements ChatHome
 {
-  private final int shard;
   private final Map<UUID, ChatRoom> chatrooms;
 
 
 
+  public SimpleChatHome(Flux<ChatRoom> chatroomFlux)
+  {
+    this(chatroomFlux, null);
+  }
+
   public SimpleChatHome(
-      int shard,
+      Integer shard,
       Flux<ChatRoom> chatroomFlux)
   {
     log.info("Created SimpleChatHome for shard {}", shard);
@@ -28,7 +32,7 @@ public class SimpleChatHome implements ChatHome
     chatroomFlux
         .filter(chatRoom ->
         {
-          if (shard > -1 && chatRoom.getShard() == shard)
+          if (shard == null && chatRoom.getShard() == shard)
           {
             return true;
           }
@@ -43,7 +47,6 @@ public class SimpleChatHome implements ChatHome
         })
         .toStream()
         .forEach(chatroom -> chatrooms.put(chatroom.getId(), chatroom));
-    this.shard = shard;
   }