WIP
authorKai Moritz <kai@juplo.de>
Fri, 15 Sep 2023 19:35:17 +0000 (21:35 +0200)
committerKai Moritz <kai@juplo.de>
Fri, 15 Sep 2023 19:35:17 +0000 (21:35 +0200)
src/main/java/de/juplo/kafka/chat/backend/implementation/kafka/DataChannel.java

index d2d6f30..181f7bf 100644 (file)
@@ -19,6 +19,7 @@ import reactor.core.publisher.Mono;
 
 import java.time.*;
 import java.util.*;
+import java.util.function.Function;
 import java.util.stream.IntStream;
 
 
@@ -300,11 +301,16 @@ public class DataChannel implements Runnable, ConsumerRebalanceListener
         .getChatRoomInfo(id)
         .map(chatRoomInfo -> chatRoomData[shard].computeIfAbsent(
             id,
-            (chatRoomId) ->
-            {
-              log.info("Creating ChatRoom {} with buffer-size {}", chatRoomId, bufferSize);
-              KafkaChatMessageService service = new KafkaChatMessageService(this, chatRoomId);
-              return new ChatRoomData(clock, service, bufferSize);
-            }));
+            computeChatRoomData()));
+  }
+
+  private Function<UUID, ChatRoomData> computeChatRoomData()
+  {
+    return (chatRoomId) ->
+    {
+      log.info("Creating ChatRoom {} with buffer-size {}", chatRoomId, bufferSize);
+      KafkaChatMessageService service = new KafkaChatMessageService(this, chatRoomId);
+      return new ChatRoomData(clock, service, bufferSize);
+    };
   }
 }