1 package de.juplo.kafka.chat.backend.persistence.storage.files;
3 import com.fasterxml.jackson.databind.ObjectMapper;
4 import de.juplo.kafka.chat.backend.ChatBackendProperties;
5 import de.juplo.kafka.chat.backend.persistence.StorageStrategy;
6 import de.juplo.kafka.chat.backend.persistence.inmemory.InMemoryChatRoomService;
7 import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
8 import org.springframework.context.annotation.Bean;
9 import org.springframework.context.annotation.Configuration;
11 import java.nio.file.Paths;
12 import java.time.Clock;
15 @ConditionalOnProperty(
16 prefix = "chat.backend",
18 havingValue = "files",
19 matchIfMissing = true)
21 public class FilesStorageAutoConfiguration
24 public StorageStrategy storageStrategy(
25 ChatBackendProperties properties,
29 return new FilesStorageStrategy(
30 Paths.get(properties.getStorageDirectory()),
32 properties.getChatroomBufferSize(),
33 messageFlux -> new InMemoryChatRoomService(messageFlux),