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.persistence.inmemory.ShardingStrategy;
5 import de.juplo.kafka.chat.backend.persistence.StorageStrategy;
6 import de.juplo.kafka.chat.backend.persistence.inmemory.InMemoryChatRoomService;
7 import de.juplo.kafka.chat.backend.persistence.storage.files.ChatRoomServiceFactory;
8 import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
9 import org.springframework.context.annotation.Bean;
10 import org.springframework.context.annotation.Configuration;
12 import java.time.Clock;
15 @ConditionalOnProperty(
16 prefix = "chat.backend.inmemory",
17 name = "storage-strategy",
18 havingValue = "mongodb")
20 public class MongoDbStorageConfiguration
23 public StorageStrategy storageStrategy(
24 ChatRoomRepository chatRoomRepository,
25 MessageRepository messageRepository,
26 ChatBackendProperties properties,
28 ShardingStrategy shardingStrategy,
29 ChatRoomServiceFactory chatRoomServiceFactory)
31 return new MongoDbStorageStrategy(
35 properties.getChatroomBufferSize(),
37 chatRoomServiceFactory);