From: Kai Moritz Date: Fri, 6 Jan 2023 00:33:51 +0000 (+0100) Subject: feat: Added a POST-mapping to force the storing of the data X-Git-Tag: wip~83 X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=c91dacfc3c7b3764d7c5925a4fb327677a0eadbb;p=demos%2Fkafka%2Fchat feat: Added a POST-mapping to force the storing of the data --- diff --git a/src/main/java/de/juplo/kafka/chat/backend/api/ChatBackendController.java b/src/main/java/de/juplo/kafka/chat/backend/api/ChatBackendController.java index 8fccaa9b..4aaf4f57 100644 --- a/src/main/java/de/juplo/kafka/chat/backend/api/ChatBackendController.java +++ b/src/main/java/de/juplo/kafka/chat/backend/api/ChatBackendController.java @@ -2,6 +2,7 @@ package de.juplo.kafka.chat.backend.api; import de.juplo.kafka.chat.backend.domain.ChatHome; import de.juplo.kafka.chat.backend.domain.Chatroom; +import de.juplo.kafka.chat.backend.persistence.StorageStrategy; import lombok.RequiredArgsConstructor; import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.*; @@ -10,7 +11,6 @@ import reactor.core.publisher.Mono; import java.time.Clock; import java.time.LocalDateTime; -import java.util.Collection; import java.util.Optional; import java.util.UUID; import java.util.stream.Stream; @@ -22,6 +22,7 @@ public class ChatBackendController { private final ChatHome chatHome; private final Clock clock; + private final StorageStrategy storageStrategy; @PostMapping("create") @@ -115,4 +116,10 @@ public class ChatBackendController .log() .map(message -> MessageTo.from(message)); } + + @PostMapping("/store") + public void store() + { + storageStrategy.writeChatrooms(Flux.fromStream(chatHome.list())); + } }