X-Git-Url: http://juplo.de/gitweb/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fde%2Fjuplo%2Fkafka%2Fchat%2Fbackend%2Fimplementation%2Finmemory%2FSimpleChatHomeService.java;h=8e3cc4305b3df480059eb4d934996f8c36f4bd7e;hb=900422dccb5a92fbceac34caa5e614b0d7f05ad7;hp=d568a9b49bc0a7350c49173e2b1ab39ed1794276;hpb=4f2a6dfe5a1c620ad795328853c1be71a2581771;p=demos%2Fkafka%2Fchat diff --git a/src/main/java/de/juplo/kafka/chat/backend/implementation/inmemory/SimpleChatHomeService.java b/src/main/java/de/juplo/kafka/chat/backend/implementation/inmemory/SimpleChatHomeService.java index d568a9b4..8e3cc430 100644 --- a/src/main/java/de/juplo/kafka/chat/backend/implementation/inmemory/SimpleChatHomeService.java +++ b/src/main/java/de/juplo/kafka/chat/backend/implementation/inmemory/SimpleChatHomeService.java @@ -18,24 +18,24 @@ public class SimpleChatHomeService implements ChatHomeService private final Map chatRoomInfo; private final Map chatRoomData; private final Clock clock; - private final int bufferSize; + private final int historyLimit; public SimpleChatHomeService( Clock clock, - int bufferSize) + int historyLimit) { this( null, clock, - bufferSize); + historyLimit); } public SimpleChatHomeService( Integer shard, Clock clock, - int bufferSize) + int historyLimit) { log.debug("Creating SimpleChatHomeService"); @@ -43,7 +43,7 @@ public class SimpleChatHomeService implements ChatHomeService this.chatRoomInfo = new HashMap<>(); this.chatRoomData = new HashMap<>(); this.clock = clock; - this.bufferSize = bufferSize; + this.historyLimit = historyLimit; } @@ -76,12 +76,13 @@ public class SimpleChatHomeService implements ChatHomeService new InMemoryChatMessageService(chatRoomId); chatRoomInfo.put(chatRoomId, info); - chatRoomData.put( - info.getId(), + ChatRoomData chatRoomData = new ChatRoomData( clock, chatMessageService, - bufferSize)); + historyLimit); + chatRoomData.activate(); + this.chatRoomData.put(info.getId(), chatRoomData); return chatMessageService.restore(storageStrategy); }) @@ -95,11 +96,12 @@ public class SimpleChatHomeService implements ChatHomeService @Override public Mono createChatRoom(UUID id, String name) { - log.info("Creating ChatRoom with buffer-size {}", bufferSize); + log.info("Creating ChatRoom with history-limit {}", historyLimit); ChatMessageService service = new InMemoryChatMessageService(id); ChatRoomInfo chatRoomInfo = new ChatRoomInfo(id, name, shard); this.chatRoomInfo.put(id, chatRoomInfo); - ChatRoomData chatRoomData = new ChatRoomData(clock, service, bufferSize); + ChatRoomData chatRoomData = new ChatRoomData(clock, service, historyLimit); + chatRoomData.activate(); this.chatRoomData.put(id, chatRoomData); return Mono.just(chatRoomInfo); }