WIP:callbacks
authorKai Moritz <kai@juplo.de>
Sun, 18 Feb 2024 16:34:40 +0000 (17:34 +0100)
committerKai Moritz <kai@juplo.de>
Sun, 18 Feb 2024 16:34:40 +0000 (17:34 +0100)
src/main/java/de/juplo/kafka/chat/backend/storage/files/FilesStorageStrategy.java
src/main/java/de/juplo/kafka/chat/backend/storage/mongodb/MongoDbStorageStrategy.java
src/main/java/de/juplo/kafka/chat/backend/storage/nostorage/NoStorageStorageConfiguration.java

index 1de0b44..cb7dd31 100644 (file)
@@ -121,9 +121,7 @@ public class FilesStorageStrategy implements StorageStrategy
   @Override
   public void writeChatRoomData(
       UUID chatRoomId,
-      Flux<Message> messageFlux,
-      SuccessCallback successCallback,
-      FailureCallback failureCallback)
+      Flux<Message> messageFlux)
   {
     Path path = chatroomPath(chatRoomId);
     log.info("Writing messages for {} to {}", chatRoomId, path);
@@ -174,12 +172,10 @@ public class FilesStorageStrategy implements StorageStrategy
               throw new RuntimeException(e);
             }
           });
-
-      successCallback.accept(chatRoomId);
     }
     catch (IOException e)
     {
-      failureCallback.accept(chatRoomId, e);
+      throw new RuntimeException(e);
     }
   }
 
index 972122e..b1bead9 100644 (file)
@@ -41,16 +41,10 @@ public class MongoDbStorageStrategy implements StorageStrategy
   }
 
   @Override
-  public void writeChatRoomData(
-      UUID chatRoomId,
-      Flux<Message> messageFlux,
-      SuccessCallback successCallback,
-      FailureCallback failureCallback)
+  public void writeChatRoomData(UUID chatRoomId, Flux<Message> messageFlux)
   {
     messageFlux
         .map(message -> MessageTo.from(chatRoomId, message))
-        .doOnComplete(() -> successCallback.accept(chatRoomId))
-        .doOnError(throwable -> failureCallback.accept(chatRoomId, throwable))
         .subscribe(messageTo -> messageRepository.save(messageTo));
   }
 
index 376679a..1b20aa3 100644 (file)
@@ -41,15 +41,7 @@ public class NoStorageStorageConfiguration
       }
 
       @Override
-      public void writeChatRoomData(
-          UUID chatRoomId,
-          Flux<Message> messageFlux,
-          SuccessCallback successCallback,
-          FailureCallback failureCallback
-      )
-      {
-        successCallback.accept(chatRoomId);
-      }
+      public void writeChatRoomData(UUID chatRoomId, Flux<Message> messageFlux) {}
 
       @Override
       public Flux<Message> readChatRoomData(UUID chatRoomId)