refactor: Streamlined API of `Chatroom` - all return-types are reactive
authorKai Moritz <kai@juplo.de>
Wed, 28 Dec 2022 16:38:00 +0000 (17:38 +0100)
committerKai Moritz <kai@juplo.de>
Sun, 15 Jan 2023 18:35:59 +0000 (19:35 +0100)
src/main/java/de/juplo/kafka/chat/backend/domain/Chatroom.java

index 115dcd6..e1638aa 100644 (file)
@@ -10,7 +10,6 @@ import reactor.core.publisher.Sinks;
 
 import java.time.LocalDateTime;
 import java.util.*;
-import java.util.stream.Stream;
 
 
 @RequiredArgsConstructor
@@ -72,16 +71,16 @@ public class Chatroom
     return sink.asFlux();
   }
 
-  public Stream<Message> getMessages(long first, long last)
+  public Flux<Message> getMessages(long first, long last)
   {
-    return messages
+    return Flux.fromStream(messages
         .values()
         .stream()
         .filter(message ->
         {
           long serial = message.getSerialNumber();
           return serial >= first && serial <= last;
-        });
+        }));
   }