WIP:callbacks
authorKai Moritz <kai@juplo.de>
Sun, 18 Feb 2024 15:10:07 +0000 (16:10 +0100)
committerKai Moritz <kai@juplo.de>
Sun, 18 Feb 2024 15:10:07 +0000 (16:10 +0100)
src/main/java/de/juplo/kafka/chat/backend/implementation/StorageStrategy.java

index ba8bc23..9fb115e 100644 (file)
@@ -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<ChatRoomInfo> chatRoomInfoFlux);
@@ -49,4 +49,14 @@ public interface StorageStrategy
 
   interface SuccessCallback extends Consumer<UUID> {}
   interface FailureCallback extends BiConsumer<UUID, Throwable> {}
+
+  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);
+  }
 }