@Autowired
ChatBackendProperties properties;
@Autowired
- ChatHome[] chatHomes;
+ ChatHome chatHome;
@Autowired
StorageStrategy storageStrategy;
@PreDestroy
public void onExit()
{
- for (int shard = 0; shard < chatHomes.length; shard++)
- storageStrategy.write(chatHomes[shard].getChatRooms(shard));
+ storageStrategy.write(chatHome.getChatRooms());
}
public static void main(String[] args)
package de.juplo.kafka.chat.backend.domain;
+import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import java.util.*;
+@RequiredArgsConstructor
@Slf4j
public class ChatHome
{
private final ChatHomeService service;
- public ChatHome(ChatHomeService service)
- {
- log.info("Created ChatHome with ChatHomeService {}", service);
- }
-
-
public Mono<ChatRoom> getChatRoom(UUID id)
{
return service
.switchIfEmpty(Mono.error(() -> new UnknownChatroomException(id)));
}
- public Flux<ChatRoom> getChatRooms(int shard)
+ public Flux<ChatRoom> getChatRooms()
{
- return service.getChatRooms(shard);
+ return service.getChatRooms();
}
}