projects
/
demos
/
kafka
/
chat
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
refactor: One stream -> using `flatMap` instead of an inner `subscribe`
[demos/kafka/chat]
/
src
/
main
/
java
/
de
/
juplo
/
kafka
/
chat
/
backend
/
storage
/
files
/
FilesStorageStrategy.java
diff --git
a/src/main/java/de/juplo/kafka/chat/backend/storage/files/FilesStorageStrategy.java
b/src/main/java/de/juplo/kafka/chat/backend/storage/files/FilesStorageStrategy.java
index
7e04a96
..
cdb4f0d
100644
(file)
--- a/
src/main/java/de/juplo/kafka/chat/backend/storage/files/FilesStorageStrategy.java
+++ b/
src/main/java/de/juplo/kafka/chat/backend/storage/files/FilesStorageStrategy.java
@@
-35,7
+35,7
@@
public class FilesStorageStrategy implements StorageStrategy
@Override
@Override
- public
void
writeChatRoomInfo(Flux<ChatRoomInfo> chatRoomInfoFlux)
+ public
Flux<ChatRoomInfo>
writeChatRoomInfo(Flux<ChatRoomInfo> chatRoomInfoFlux)
{
Path path = chatroomsPath();
log.info("Writing chatrooms to {}", path);
{
Path path = chatroomsPath();
log.info("Writing chatrooms to {}", path);
@@
-48,7
+48,7
@@
public class FilesStorageStrategy implements StorageStrategy
.getFactory()
.createGenerator(Files.newBufferedWriter(path, CREATE, TRUNCATE_EXISTING));
.getFactory()
.createGenerator(Files.newBufferedWriter(path, CREATE, TRUNCATE_EXISTING));
- chatRoomInfoFlux
+
return
chatRoomInfoFlux
.log()
.doFirst(() ->
{
.log()
.doFirst(() ->
{
@@
-86,8
+86,7
@@
public class FilesStorageStrategy implements StorageStrategy
{
throw new RuntimeException(e);
}
{
throw new RuntimeException(e);
}
- })
- .subscribe();
+ });
}
catch (IOException e)
{
}
catch (IOException e)
{
@@
-121,7
+120,7
@@
public class FilesStorageStrategy implements StorageStrategy
}
@Override
}
@Override
- public
void
writeChatRoomData(
+ public
Flux<Message>
writeChatRoomData(
UUID chatRoomId,
Flux<Message> messageFlux)
{
UUID chatRoomId,
Flux<Message> messageFlux)
{
@@
-136,7
+135,7
@@
public class FilesStorageStrategy implements StorageStrategy
.getFactory()
.createGenerator(Files.newBufferedWriter(path, CREATE, TRUNCATE_EXISTING));
.getFactory()
.createGenerator(Files.newBufferedWriter(path, CREATE, TRUNCATE_EXISTING));
- messageFlux
+
return
messageFlux
.log()
.doFirst(() ->
{
.log()
.doFirst(() ->
{
@@
-174,8
+173,7
@@
public class FilesStorageStrategy implements StorageStrategy
{
throw new RuntimeException(e);
}
{
throw new RuntimeException(e);
}
- })
- .subscribe();
+ });
}
catch (IOException e)
{
}
catch (IOException e)
{