7e3667dff16e0a35381c3f39a2995d6df4ca807c
[demos/kafka/chat] /
1 package de.juplo.kafka.chat.backend.persistence.inmemory;
2
3 import de.juplo.kafka.chat.backend.ChatBackendProperties;
4 import de.juplo.kafka.chat.backend.persistence.StorageStrategy;
5 import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
6 import org.springframework.context.annotation.Bean;
7 import org.springframework.context.annotation.Configuration;
8
9 import java.time.Clock;
10
11
12 @ConditionalOnProperty(
13     prefix = "chat.backend",
14     name = "services",
15     havingValue = "in-memory",
16     matchIfMissing = true)
17 @Configuration
18 public class InMemoryServicesAutoConfiguration
19 {
20   @Bean
21   InMemoryChatHomeService chatHomeService(
22       StorageStrategy storageStrategy,
23       Clock clock,
24       ChatBackendProperties properties)
25   {
26     return new InMemoryChatHomeService(
27         storageStrategy.read(),
28         clock,
29         properties.getChatroomBufferSize());
30   }
31 }