package de.juplo.kafka.chat.backend;
-import de.juplo.kafka.chat.backend.domain.ChatHome;
-import de.juplo.kafka.chat.backend.domain.ChatHomeFactory;
-import de.juplo.kafka.chat.backend.domain.ChatHomeService;
-import de.juplo.kafka.chat.backend.persistence.StorageStrategy;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
+import org.springframework.boot.autoconfigure.data.mongo.MongoReactiveDataAutoConfiguration;
+import org.springframework.boot.autoconfigure.data.mongo.MongoReactiveRepositoriesAutoConfiguration;
+import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration;
+import org.springframework.boot.autoconfigure.mongo.MongoReactiveAutoConfiguration;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
public class ChatBackendConfiguration
{
@Bean
- ChatHome[] chatHomes(
- ChatHomeFactory factory,
- ChatBackendProperties properties,
- StorageStrategy storageStrategy)
+ Clock clock()
{
- ChatHome[] chatHomes = new ChatHome[properties.getInmemory().getNumShards()];
- storageStrategy
- .read()
- .subscribe(chatRoom ->
- {
- int shard = chatRoom.getShard();
- if (chatHomes[shard] == null)
- chatHomes[shard] = factory.createChatHome(shard);
- });
- return chatHomes;
+ return Clock.systemDefaultZone();
}
- @Bean
- Clock clock()
+
+ @ConditionalOnExpression("!'${chat.backend.inmemory.storage-strategy}'.toLowerCase().equals('mongodb')")
+ @Configuration
+ @EnableAutoConfiguration(exclude = {
+ MongoReactiveDataAutoConfiguration.class,
+ MongoReactiveAutoConfiguration.class,
+ MongoReactiveRepositoriesAutoConfiguration.class,
+ MongoAutoConfiguration.class })
+ public static class DisableMongoDBConfiguration
{
- return Clock.systemDefaultZone();
}
}