From 7b997f26deee123f2a60aa7c92855577432713db Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Mon, 4 Sep 2023 01:44:51 +0200 Subject: [PATCH] refactor: Renamed `ChatRoom` into `ChatRoomData` - Aligned Code --- .../de/juplo/kafka/chat/backend/domain/ChatRoomData.java | 7 +------ .../inmemory/InMemoryServicesConfiguration.java | 4 +++- .../chat/backend/persistence/inmemory/SimpleChatHome.java | 3 +-- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/main/java/de/juplo/kafka/chat/backend/domain/ChatRoomData.java b/src/main/java/de/juplo/kafka/chat/backend/domain/ChatRoomData.java index 0031bb0d..5c497316 100644 --- a/src/main/java/de/juplo/kafka/chat/backend/domain/ChatRoomData.java +++ b/src/main/java/de/juplo/kafka/chat/backend/domain/ChatRoomData.java @@ -1,6 +1,5 @@ package de.juplo.kafka.chat.backend.domain; -import lombok.Getter; import lombok.extern.slf4j.Slf4j; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @@ -19,8 +18,6 @@ public class ChatRoomData { public final static Pattern VALID_USER = Pattern.compile("^[a-z0-9-]{2,}$"); - @Getter - private final UUID id; private final ChatRoomService service; private final Clock clock; private final int bufferSize; @@ -28,13 +25,11 @@ public class ChatRoomData public ChatRoomData( - UUID id, ChatRoomService service, Clock clock, int bufferSize) { - log.info("Created ChatRoom {id} with buffer-size {}", id, bufferSize); - this.id = id; + log.info("Created ChatRoom with buffer-size {}", bufferSize); this.service = service; this.clock = clock; this.bufferSize = bufferSize; 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 76080c9c..47c223e8 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 @@ -47,6 +47,7 @@ public class InMemoryServicesConfiguration ChatHome kafkalikeShardingChatHome( ChatBackendProperties properties, StorageStrategy storageStrategy, + ChatRoomServiceFactory chatRoomServiceFactory, Clock clock) { int numShards = properties.getInmemory().getNumShards(); @@ -55,7 +56,8 @@ public class InMemoryServicesConfiguration .of(properties.getInmemory().getOwnedShards()) .forEach(shard -> chatHomes[shard] = new SimpleChatHome( shard, - storageStrategy.readChatRoomData(), + 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 961cea2e..862c7048 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 @@ -75,7 +75,6 @@ public class SimpleChatHome implements ChatHome chatRoomData.put( info.getId(), new ChatRoomData( - chatRoomId, chatRoomServiceFactory.create(messageFlux), clock, bufferSize)); @@ -91,7 +90,7 @@ public class SimpleChatHome implements ChatHome log.info("Creating ChatRoom with buffer-size {}", bufferSize); ChatRoomService service = new InMemoryChatRoomService(Flux.empty()); ChatRoomInfo chatRoomInfo = new ChatRoomInfo(id, name, shard); - ChatRoomData chatRoomData = new ChatRoomData(id, service, clock, bufferSize); + ChatRoomData chatRoomData = new ChatRoomData(service, clock, bufferSize); this.chatRoomData.put(id, chatRoomData); return Mono.just(chatRoomInfo); } -- 2.20.1