projects
/
demos
/
kafka
/
chat
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
refactor: Moved extracted the `subscribe()`-call from `StorageStrategy`
[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
cb7dd31
..
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(() ->
{
@@
-74,12
+74,13
@@
public class FilesStorageStrategy implements StorageStrategy
throw new RuntimeException(e);
}
})
throw new RuntimeException(e);
}
})
- .
subscribe
(chatRoomInfo ->
+ .
map
(chatRoomInfo ->
{
try
{
ChatRoomInfoTo chatRoomInfoTo = ChatRoomInfoTo.from(chatRoomInfo);
generator.writeObject(chatRoomInfoTo);
{
try
{
ChatRoomInfoTo chatRoomInfoTo = ChatRoomInfoTo.from(chatRoomInfo);
generator.writeObject(chatRoomInfoTo);
+ return chatRoomInfo;
}
catch (IOException e)
{
}
catch (IOException e)
{
@@
-119,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)
{
@@
-134,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(() ->
{
@@
-160,12
+161,13
@@
public class FilesStorageStrategy implements StorageStrategy
throw new RuntimeException(e);
}
})
throw new RuntimeException(e);
}
})
- .
subscribe
(message ->
+ .
map
(message ->
{
try
{
MessageTo messageTo = MessageTo.from(message);
generator.writeObject(messageTo);
{
try
{
MessageTo messageTo = MessageTo.from(message);
generator.writeObject(messageTo);
+ return message;
}
catch (IOException e)
{
}
catch (IOException e)
{