feat: Introduced counting of stored instances in `StorageStrategy`
authorKai Moritz <kai@juplo.de>
Tue, 20 Feb 2024 12:02:09 +0000 (13:02 +0100)
committerKai Moritz <kai@juplo.de>
Tue, 20 Feb 2024 12:02:09 +0000 (13:02 +0100)
src/main/java/de/juplo/kafka/chat/backend/implementation/StorageStrategy.java

index 647ac52..87208dc 100644 (file)
@@ -24,12 +24,13 @@ public interface StorageStrategy
                 .getChatRoomData(chatRoomInfo.getId())
                 .flatMapMany(chatRoomData -> chatRoomData.getMessages())
             )
-            .then()
-            .doOnSuccess(empty -> log.info("Stored {}", chatRoomInfo))
+            .count()
+            .doOnSuccess(count -> log.info("Stored {} messages for {}", count, chatRoomInfo))
             .doOnError(throwable -> log.error("Could not store {}: {}", chatRoomInfo, throwable)))
-        .then()
-        .doOnSuccess(empty -> log.info("Stored {}", chatHomeService))
-        .doOnError(throwable -> log.error("Could not store {}: {}", chatHomeService, throwable));
+        .count()
+        .doOnSuccess(count -> log.info("Stored {} chat-rooms for {}", count, chatHomeService))
+        .doOnError(throwable -> log.error("Could not store {}: {}", chatHomeService, throwable))
+        .then();
   }
 
   Flux<ChatRoomInfo> writeChatRoomInfo(Flux<ChatRoomInfo> chatRoomInfoFlux);