From: Kai Moritz Date: Sun, 18 Feb 2024 15:10:07 +0000 (+0100) Subject: WIP:callbacks X-Git-Tag: rebase--2024-02-18--18-12~8 X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=534c8729503165ab6f247bd22435ef8f88117d8b;p=demos%2Fkafka%2Fchat WIP:callbacks --- diff --git a/src/main/java/de/juplo/kafka/chat/backend/implementation/StorageStrategy.java b/src/main/java/de/juplo/kafka/chat/backend/implementation/StorageStrategy.java index ba8bc23a..9fb115e3 100644 --- a/src/main/java/de/juplo/kafka/chat/backend/implementation/StorageStrategy.java +++ b/src/main/java/de/juplo/kafka/chat/backend/implementation/StorageStrategy.java @@ -34,8 +34,8 @@ public interface StorageStrategy writeChatRoomData( chatRoomId, messageFlux, - (id) -> log.info("Successfully stored chat-room {}", id), - (id, throwable) -> log.error("Could not store chat-room {}: {}", id, throwable)); + (id) -> logSuccess(id), + (id, throwable) -> logFailure(id, throwable)); } void writeChatRoomInfo(Flux chatRoomInfoFlux); @@ -49,4 +49,14 @@ public interface StorageStrategy interface SuccessCallback extends Consumer {} interface FailureCallback extends BiConsumer {} + + default void logSuccess(UUID chatRoomId) + { + log.info("Successfully stored chat-room {}", chatRoomId); + } + + default void logFailure(UUID chatRoomId, Throwable throwable) + { + log.error("Could not store chat-room {}: {}", chatRoomId, throwable); + } }