ffed29921720c054517ab3b94e42ad3a12992ecd
[demos/kafka/chat] /
1 package de.juplo.kafka.chat.backend.persistence.storage.nostorage;
2
3 import de.juplo.kafka.chat.backend.domain.ChatRoom;
4 import de.juplo.kafka.chat.backend.persistence.StorageStrategy;
5 import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
6 import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
7 import org.springframework.boot.autoconfigure.data.mongo.MongoRepositoriesAutoConfiguration;
8 import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration;
9 import org.springframework.context.annotation.Bean;
10 import org.springframework.context.annotation.Configuration;
11 import reactor.core.publisher.Flux;
12
13
14 @ConditionalOnProperty(
15     prefix = "chat.backend.inmemory",
16     name = "storage-strategy",
17     havingValue = "none",
18     matchIfMissing = true)
19 @Configuration
20 @EnableAutoConfiguration(
21     exclude = {
22         MongoRepositoriesAutoConfiguration.class,
23         MongoAutoConfiguration.class })
24 public class NoStorageStorageConfiguration
25 {
26   @Bean
27   public StorageStrategy storageStrategy()
28   {
29     return new StorageStrategy()
30     {
31       @Override
32       public void write(Flux<ChatRoom> chatroomFlux) {}
33
34       @Override
35       public Flux<ChatRoom> read()
36       {
37         return Flux.empty();
38       }
39     };
40   }
41 }