From: Kai Moritz Date: Mon, 4 Sep 2023 20:52:39 +0000 (+0200) Subject: refactor: Renamed `ChatRoom` into `ChatRoomData` - Aligned Code X-Git-Tag: rebase--2023-09-05--23-53~14 X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=6126d097334b15c98c5668d4d371292276a8edaa;p=demos%2Fkafka%2Fchat refactor: Renamed `ChatRoom` into `ChatRoomData` - Aligned Code --- diff --git a/src/main/java/de/juplo/kafka/chat/backend/persistence/inmemory/InMemoryServicesConfiguration.java b/src/main/java/de/juplo/kafka/chat/backend/persistence/inmemory/InMemoryServicesConfiguration.java index 47c223e8..16115825 100644 --- a/src/main/java/de/juplo/kafka/chat/backend/persistence/inmemory/InMemoryServicesConfiguration.java +++ b/src/main/java/de/juplo/kafka/chat/backend/persistence/inmemory/InMemoryServicesConfiguration.java @@ -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); diff --git a/src/main/java/de/juplo/kafka/chat/backend/persistence/inmemory/SimpleChatHome.java b/src/main/java/de/juplo/kafka/chat/backend/persistence/inmemory/SimpleChatHome.java index 51147c51..c6f33778 100644 --- a/src/main/java/de/juplo/kafka/chat/backend/persistence/inmemory/SimpleChatHome.java +++ b/src/main/java/de/juplo/kafka/chat/backend/persistence/inmemory/SimpleChatHome.java @@ -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; diff --git a/src/test/java/de/juplo/kafka/chat/backend/persistence/AbstractInMemoryStorageIT.java b/src/test/java/de/juplo/kafka/chat/backend/persistence/AbstractInMemoryStorageIT.java index b5d0cd42..d984db3a 100644 --- a/src/test/java/de/juplo/kafka/chat/backend/persistence/AbstractInMemoryStorageIT.java +++ b/src/test/java/de/juplo/kafka/chat/backend/persistence/AbstractInMemoryStorageIT.java @@ -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); diff --git a/src/test/java/de/juplo/kafka/chat/backend/persistence/AbstractStorageStrategyIT.java b/src/test/java/de/juplo/kafka/chat/backend/persistence/AbstractStorageStrategyIT.java index f9cd11f1..5132c656 100644 --- a/src/test/java/de/juplo/kafka/chat/backend/persistence/AbstractStorageStrategyIT.java +++ b/src/test/java/de/juplo/kafka/chat/backend/persistence/AbstractStorageStrategyIT.java @@ -27,7 +27,7 @@ public abstract class AbstractStorageStrategyIT protected void stop() { - getStorageStrategy().writeChatRoomData(chathome.getChatRoomData()); + getStorageStrategy().write(chathome); } @Test diff --git a/src/test/java/de/juplo/kafka/chat/backend/persistence/inmemory/ShardedChatHomeTest.java b/src/test/java/de/juplo/kafka/chat/backend/persistence/inmemory/ShardedChatHomeTest.java index 22c37d18..652ade84 100644 --- a/src/test/java/de/juplo/kafka/chat/backend/persistence/inmemory/ShardedChatHomeTest.java +++ b/src/test/java/de/juplo/kafka/chat/backend/persistence/inmemory/ShardedChatHomeTest.java @@ -27,7 +27,7 @@ public class ShardedChatHomeTest extends ChatHomeWithShardsTest .of(ownedShards()) .forEach(shard -> chatHomes[shard] = new SimpleChatHome( shard, - storageStrategy.readChatRoomData(), + storageStrategy, clock, bufferSize())); diff --git a/src/test/java/de/juplo/kafka/chat/backend/persistence/inmemory/SimpleChatHomeTest.java b/src/test/java/de/juplo/kafka/chat/backend/persistence/inmemory/SimpleChatHomeTest.java index 1140f69b..7103bb67 100644 --- a/src/test/java/de/juplo/kafka/chat/backend/persistence/inmemory/SimpleChatHomeTest.java +++ b/src/test/java/de/juplo/kafka/chat/backend/persistence/inmemory/SimpleChatHomeTest.java @@ -22,7 +22,7 @@ public class SimpleChatHomeTest extends ChatHomeTest Clock clock) { return new SimpleChatHome( - storageStrategy.readChatRoomData(), + storageStrategy, clock, bufferSize()); }