1 package de.juplo.kafka.chat.backend.persistence.storage.mongodb;
3 import de.juplo.kafka.chat.backend.ChatBackendProperties;
4 import de.juplo.kafka.chat.backend.api.ShardingStrategy;
5 import de.juplo.kafka.chat.backend.persistence.StorageStrategy;
6 import de.juplo.kafka.chat.backend.persistence.inmemory.InMemoryChatRoomService;
7 import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
8 import org.springframework.context.annotation.Bean;
9 import org.springframework.context.annotation.Configuration;
11 import java.time.Clock;
14 @ConditionalOnProperty(
15 prefix = "chat.backend.inmemory",
16 name = "storage-strategy",
17 havingValue = "mongodb")
19 public class MongoDbStorageConfiguration
22 public StorageStrategy storageStrategy(
23 ChatRoomRepository chatRoomRepository,
24 ChatBackendProperties properties,
26 ShardingStrategy shardingStrategy)
28 return new MongoDbStorageStrategy(
31 properties.getChatroomBufferSize(),
33 messageFlux -> new InMemoryChatRoomService(messageFlux));