name = "sharding-strategy",
havingValue = "none",
matchIfMissing = true)
- ChatHomeService noneShardingChatHome(
+ SimpleChatHomeService noneShardingChatHome(
ChatBackendProperties properties,
StorageStrategy storageStrategy,
Clock clock)
{
- return new SimpleChatHomeService(
- storageStrategy,
+ SimpleChatHomeService chatHomeService = new SimpleChatHomeService(
clock,
properties.getChatroomBufferSize());
+ chatHomeService.restore(storageStrategy).block();
+ return chatHomeService;
}
@Bean
prefix = "chat.backend.inmemory",
name = "sharding-strategy",
havingValue = "kafkalike")
- ChatHomeService kafkalikeShardingChatHome(
+ ShardedChatHomeService kafkalikeShardingChatHome(
ChatBackendProperties properties,
StorageStrategy storageStrategy,
Clock clock)
SimpleChatHomeService[] chatHomes = new SimpleChatHomeService[numShards];
IntStream
.of(properties.getInmemory().getOwnedShards())
- .forEach(shard -> chatHomes[shard] = new SimpleChatHomeService(
- shard,
- storageStrategy,
- clock,
- properties.getChatroomBufferSize()));
+ .forEach(shard ->
+ {
+ SimpleChatHomeService service = chatHomes[shard] = new SimpleChatHomeService(
+ shard,
+ clock,
+ properties.getChatroomBufferSize());
+ service.restore(storageStrategy).block();
+ });
ShardingStrategy strategy = new KafkaLikeShardingStrategy(numShards);
return new ShardedChatHomeService(
properties.getInstanceId(),