ab24bb8a4d1b086db3599fa1167e633710d28201
[demos/kafka/chat] /
1 package de.juplo.kafka.chat.backend.persistence.storage.nostorage;
2
3 import de.juplo.kafka.chat.backend.domain.ChatRoomInfo;
4 import de.juplo.kafka.chat.backend.domain.Message;
5 import de.juplo.kafka.chat.backend.persistence.StorageStrategy;
6 import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
7 import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
8 import org.springframework.boot.autoconfigure.data.mongo.MongoRepositoriesAutoConfiguration;
9 import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration;
10 import org.springframework.context.annotation.Bean;
11 import org.springframework.context.annotation.Configuration;
12 import reactor.core.publisher.Flux;
13
14 import java.util.UUID;
15
16
17 @ConditionalOnProperty(
18     prefix = "chat.backend.inmemory",
19     name = "storage-strategy",
20     havingValue = "none",
21     matchIfMissing = true)
22 @Configuration
23 @EnableAutoConfiguration(
24     exclude = {
25         MongoRepositoriesAutoConfiguration.class,
26         MongoAutoConfiguration.class })
27 public class NoStorageStorageConfiguration
28 {
29   @Bean
30   public StorageStrategy storageStrategy()
31   {
32     return new StorageStrategy()
33     {
34       @Override
35       public void writeChatRoomInfo(Flux<ChatRoomInfo> chatRoomInfoFlux) {}
36
37       @Override
38       public Flux<ChatRoomInfo> readChatRoomInfo()
39       {
40         return Flux.empty();
41       }
42
43       @Override
44       public void writeChatRoomData(UUID chatRoomId, Flux<Message> messageFlux) {}
45
46       @Override
47       public Flux<Message> readChatRoomData(UUID chatRoomId)
48       {
49         return Flux.empty();
50       }
51     };
52   }
53 }