Kai Moritz [Sat, 7 Jan 2023 01:16:57 +0000 (02:16 +0100)]
fix: The sink is recreated, if it gets canceled
- The sink is automatically cancelled, if the last consumer leaves.
- Turning auto-cancel of, is not an option, because this buffers new
messages, until the buffer overflows, after which new messages are
droped. Hence, if a new subscriber arrives, it would see some old
messages and then, after a gap, current messages.
- Because of that, the sink is now automatically recreated, if the
last subscriber leaves and triggers the automatically cancelation
of the sink.
- The sink can be recreated without conflicts, because all methods,
that may access the sink are synchronized.
Kai Moritz [Wed, 28 Dec 2022 16:23:30 +0000 (17:23 +0100)]
refactor: Refined field-names of `Message` and `MessageTo`
- Choosed longer and more descriptive field-names for the domain-class
`Message`.
- Choosed short names for the TO-class `MessageTO`, which is serialized as
JSON.
Kai Moritz [Wed, 21 Dec 2022 17:57:23 +0000 (18:57 +0100)]
feat: implemented a listen-method for the chat-service based on a Flux
- Switched the return-type of `Chatroom.addMessage()` to `Mono<Message>`.
- Added an inner method, that "persists" the message and also returns
`Mono<Message>`.
- `addMessage()` calls `persistMessage()`, peeks into the subscription and
emits the `Message` to an internal `Sink.multy()` of the `Chatroom`.
- `Chatroom.listen()` creates a `Flux` from the internal Sink, so that
multiple subscribers can listen on the sink and all retrieve the current
messages in parallel.