refactor: Renamed `ChatRoom` into `ChatRoomData` - Aligned Code
authorKai Moritz <kai@juplo.de>
Mon, 4 Sep 2023 20:52:39 +0000 (22:52 +0200)
committerKai Moritz <kai@juplo.de>
Mon, 4 Sep 2023 20:52:39 +0000 (22:52 +0200)
src/main/java/de/juplo/kafka/chat/backend/persistence/inmemory/InMemoryServicesConfiguration.java
src/main/java/de/juplo/kafka/chat/backend/persistence/inmemory/SimpleChatHome.java
src/test/java/de/juplo/kafka/chat/backend/persistence/AbstractInMemoryStorageIT.java
src/test/java/de/juplo/kafka/chat/backend/persistence/AbstractStorageStrategyIT.java
src/test/java/de/juplo/kafka/chat/backend/persistence/inmemory/ShardedChatHomeTest.java
src/test/java/de/juplo/kafka/chat/backend/persistence/inmemory/SimpleChatHomeTest.java

index 47c223e..1611582 100644 (file)
@@ -29,12 +29,10 @@ public class InMemoryServicesConfiguration
   ChatHome noneShardingChatHome(
       ChatBackendProperties properties,
       StorageStrategy storageStrategy,
-      ChatRoomServiceFactory chatRoomServiceFactory,
       Clock clock)
   {
     return new SimpleChatHome(
         storageStrategy,
-        chatRoomServiceFactory,
         clock,
         properties.getChatroomBufferSize());
   }
@@ -57,7 +55,6 @@ public class InMemoryServicesConfiguration
         .forEach(shard -> chatHomes[shard] = new SimpleChatHome(
             shard,
             storageStrategy,
-            chatRoomServiceFactory,
             clock,
             properties.getChatroomBufferSize()));
     ShardingStrategy strategy = new KafkaLikeShardingStrategy(numShards);
index 51147c5..c6f3377 100644 (file)
@@ -24,14 +24,12 @@ public class SimpleChatHome implements ChatHome
 
   public SimpleChatHome(
       StorageStrategy storageStrategy,
-      ChatRoomServiceFactory chatRoomServiceFactory,
       Clock clock,
       int bufferSize)
   {
     this(
         null,
         storageStrategy,
-        chatRoomServiceFactory,
         clock,
         bufferSize);
   }
@@ -39,7 +37,6 @@ public class SimpleChatHome implements ChatHome
   public SimpleChatHome(
       Integer shard,
       StorageStrategy storageStrategy,
-      ChatRoomServiceFactory chatRoomServiceFactory,
       Clock clock,
       int bufferSize)
   {
@@ -76,7 +73,7 @@ public class SimpleChatHome implements ChatHome
               info.getId(),
               new ChatRoomData(
                   clock,
-                  chatRoomServiceFactory.create(messageFlux),
+                  new InMemoryChatRoomService(messageFlux),
                   bufferSize));
         });
     this.clock = clock;
index b5d0cd4..d984db3 100644 (file)
@@ -2,6 +2,7 @@ package de.juplo.kafka.chat.backend.persistence;
 
 import de.juplo.kafka.chat.backend.domain.ChatHome;
 import de.juplo.kafka.chat.backend.persistence.inmemory.SimpleChatHome;
+import de.juplo.kafka.chat.backend.persistence.storage.files.ChatRoomServiceFactory;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 
@@ -22,7 +23,7 @@ public abstract class AbstractInMemoryStorageIT extends AbstractStorageStrategyI
       int bufferSize = 8;
 
       SimpleChatHome simpleChatHome = new SimpleChatHome(
-          getStorageStrategy().readChatRoomData(),
+          getStorageStrategy(),
           clock,
           bufferSize);
 
index f9cd11f..5132c65 100644 (file)
@@ -27,7 +27,7 @@ public abstract class AbstractStorageStrategyIT
 
   protected void stop()
   {
-    getStorageStrategy().writeChatRoomData(chathome.getChatRoomData());
+    getStorageStrategy().write(chathome);
   }
 
   @Test
index 22c37d1..652ade8 100644 (file)
@@ -27,7 +27,7 @@ public class ShardedChatHomeTest extends ChatHomeWithShardsTest
           .of(ownedShards())
           .forEach(shard -> chatHomes[shard] = new SimpleChatHome(
               shard,
-              storageStrategy.readChatRoomData(),
+              storageStrategy,
               clock,
               bufferSize()));
 
index 1140f69..7103bb6 100644 (file)
@@ -22,7 +22,7 @@ public class SimpleChatHomeTest extends ChatHomeTest
         Clock clock)
     {
       return new SimpleChatHome(
-          storageStrategy.readChatRoomData(),
+          storageStrategy,
           clock,
           bufferSize());
     }