From: Kai Moritz Date: Sun, 8 Jan 2023 09:34:09 +0000 (+0100) Subject: refactore: Renamed `ChatroomService` to `ChatRoomService` -- Rename X-Git-Tag: TEST~38 X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=b4f394bf0be34d706714a4b0f6f9041d84a0c20b;p=demos%2Fkafka%2Fchat refactore: Renamed `ChatroomService` to `ChatRoomService` -- Rename --- diff --git a/src/main/java/de/juplo/kafka/chat/backend/domain/ChatHomeService.java b/src/main/java/de/juplo/kafka/chat/backend/domain/ChatHomeService.java index 5508f24a..69ed5f42 100644 --- a/src/main/java/de/juplo/kafka/chat/backend/domain/ChatHomeService.java +++ b/src/main/java/de/juplo/kafka/chat/backend/domain/ChatHomeService.java @@ -3,7 +3,7 @@ package de.juplo.kafka.chat.backend.domain; import java.util.UUID; -public interface ChatHomeService +public interface ChatHomeService { ChatRoom createChatroom(UUID id, String name); } diff --git a/src/main/java/de/juplo/kafka/chat/backend/domain/ChatRoom.java b/src/main/java/de/juplo/kafka/chat/backend/domain/ChatRoom.java index bed91c76..0fdea33e 100644 --- a/src/main/java/de/juplo/kafka/chat/backend/domain/ChatRoom.java +++ b/src/main/java/de/juplo/kafka/chat/backend/domain/ChatRoom.java @@ -17,19 +17,19 @@ public class ChatRoom private final UUID id; @Getter private final String name; - private final ChatroomService chatroomService; + private final ChatRoomService service; private final int bufferSize; private Sinks.Many sink; public ChatRoom( UUID id, String name, - ChatroomService chatroomService, + ChatRoomService service, int bufferSize) { this.id = id; this.name = name; - this.chatroomService = chatroomService; + this.service = service; this.bufferSize = bufferSize; this.sink = createSink(); } @@ -41,7 +41,7 @@ public class ChatRoom String user, String text) { - return chatroomService + return service .persistMessage(Message.MessageKey.of(user, id), timestamp, text) .doOnNext(message -> { @@ -57,7 +57,7 @@ public class ChatRoom public Mono getMessage(String username, Long messageId) { Message.MessageKey key = Message.MessageKey.of(username, messageId); - return chatroomService.getMessage(key); + return service.getMessage(key); } synchronized public Flux listen() @@ -74,7 +74,7 @@ public class ChatRoom public Flux getMessages(long first, long last) { - return chatroomService.getMessages(first, last); + return service.getMessages(first, last); } private Sinks.Many createSink() diff --git a/src/main/java/de/juplo/kafka/chat/backend/domain/ChatRoomService.java b/src/main/java/de/juplo/kafka/chat/backend/domain/ChatRoomService.java index 1e7e8c72..374a442b 100644 --- a/src/main/java/de/juplo/kafka/chat/backend/domain/ChatRoomService.java +++ b/src/main/java/de/juplo/kafka/chat/backend/domain/ChatRoomService.java @@ -6,7 +6,7 @@ import reactor.core.publisher.Mono; import java.time.LocalDateTime; -public interface ChatroomService +public interface ChatRoomService { Mono persistMessage( Message.MessageKey key, diff --git a/src/main/java/de/juplo/kafka/chat/backend/persistence/InMemoryChatHomeService.java b/src/main/java/de/juplo/kafka/chat/backend/persistence/InMemoryChatHomeService.java index 006f9767..e57b99b7 100644 --- a/src/main/java/de/juplo/kafka/chat/backend/persistence/InMemoryChatHomeService.java +++ b/src/main/java/de/juplo/kafka/chat/backend/persistence/InMemoryChatHomeService.java @@ -9,7 +9,7 @@ import java.util.UUID; @RequiredArgsConstructor -public class InMemoryChatHomeService implements ChatHomeService +public class InMemoryChatHomeService implements ChatHomeService { private final int bufferSize; @@ -17,16 +17,16 @@ public class InMemoryChatHomeService implements ChatHomeService()); - return new ChatRoom(id, name, chatroomService, bufferSize); + InMemoryChatRoomService service = + new InMemoryChatRoomService(new LinkedHashMap<>()); + return new ChatRoom(id, name, service, bufferSize); } public ChatRoom restoreChatroom( UUID id, String name, - InMemoryChatroomService chatroomService) + InMemoryChatRoomService service) { - return new ChatRoom(id, name, chatroomService, bufferSize); + return new ChatRoom(id, name, service, bufferSize); } } diff --git a/src/main/java/de/juplo/kafka/chat/backend/persistence/InMemoryChatRoomService.java b/src/main/java/de/juplo/kafka/chat/backend/persistence/InMemoryChatRoomService.java index e06709ff..1831037e 100644 --- a/src/main/java/de/juplo/kafka/chat/backend/persistence/InMemoryChatRoomService.java +++ b/src/main/java/de/juplo/kafka/chat/backend/persistence/InMemoryChatRoomService.java @@ -2,7 +2,7 @@ package de.juplo.kafka.chat.backend.persistence; import de.juplo.kafka.chat.backend.domain.Message; import de.juplo.kafka.chat.backend.domain.MessageMutationException; -import de.juplo.kafka.chat.backend.domain.ChatroomService; +import de.juplo.kafka.chat.backend.domain.ChatRoomService; import lombok.extern.slf4j.Slf4j; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @@ -12,17 +12,17 @@ import java.util.LinkedHashMap; @Slf4j -public class InMemoryChatroomService implements ChatroomService +public class InMemoryChatRoomService implements ChatRoomService { private final LinkedHashMap messages; - public InMemoryChatroomService(LinkedHashMap messages) + public InMemoryChatRoomService(LinkedHashMap messages) { this.messages = messages; } - public InMemoryChatroomService(Flux messageFlux) + public InMemoryChatRoomService(Flux messageFlux) { log.debug("Creating InMemoryChatroomService"); messages = new LinkedHashMap<>(); diff --git a/src/main/java/de/juplo/kafka/chat/backend/persistence/LocalJsonFilesStorageStrategy.java b/src/main/java/de/juplo/kafka/chat/backend/persistence/LocalJsonFilesStorageStrategy.java index 038ab7a3..706fbe30 100644 --- a/src/main/java/de/juplo/kafka/chat/backend/persistence/LocalJsonFilesStorageStrategy.java +++ b/src/main/java/de/juplo/kafka/chat/backend/persistence/LocalJsonFilesStorageStrategy.java @@ -100,8 +100,8 @@ public class LocalJsonFilesStorageStrategy implements StorageStrategy .log() .map(chatRoomTo -> { - InMemoryChatroomService chatroomService = - new InMemoryChatroomService(readMessages(chatRoomTo)); + InMemoryChatRoomService chatroomService = + new InMemoryChatRoomService(readMessages(chatRoomTo)); return service.restoreChatroom( chatRoomTo.getId(), chatRoomTo.getName(),