From 4f2a6dfe5a1c620ad795328853c1be71a2581771 Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Tue, 20 Feb 2024 16:14:22 +0100 Subject: [PATCH] feat: Added counting of restored instances --- .../inmemory/InMemoryChatMessageService.java | 7 ++++--- .../implementation/inmemory/SimpleChatHomeService.java | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main/java/de/juplo/kafka/chat/backend/implementation/inmemory/InMemoryChatMessageService.java b/src/main/java/de/juplo/kafka/chat/backend/implementation/inmemory/InMemoryChatMessageService.java index 7d4b9b62..5d5feb87 100644 --- a/src/main/java/de/juplo/kafka/chat/backend/implementation/inmemory/InMemoryChatMessageService.java +++ b/src/main/java/de/juplo/kafka/chat/backend/implementation/inmemory/InMemoryChatMessageService.java @@ -33,9 +33,10 @@ public class InMemoryChatMessageService implements ChatMessageService return messageFlux .doOnNext(message -> messages.put(message.getKey(), message)) - .then() - .doOnSuccess(empty -> log.info("Restored InMemoryChatMessageService")) - .doOnError(throwable -> log.error("Could not restore InMemoryChatMessageService")); + .count() + .doOnSuccess(count -> log.info("Restored InMemoryChatMessageService with {} messages", count)) + .doOnError(throwable -> log.error("Could not restore InMemoryChatMessageService")) + .then(); } @Override 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 371d4a87..d568a9b4 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 @@ -85,9 +85,10 @@ public class SimpleChatHomeService implements ChatHomeService return chatMessageService.restore(storageStrategy); }) - .then() - .doOnSuccess(empty -> log.info("Restored {}", this)) - .doOnError(throwable -> log.error("Could not restore {}", this)); + .count() + .doOnSuccess(count -> log.info("Restored {} with {} chat-rooms", this, count)) + .doOnError(throwable -> log.error("Could not restore {}", this)) + .then(); } -- 2.20.1