import java.net.URI;
import java.nio.file.Paths;
+import java.util.logging.Level;
@ConfigurationProperties("chat.backend")
private ServiceType services = ServiceType.inmemory;
private InMemoryServicesProperties inmemory = new InMemoryServicesProperties();
private KafkaServicesProperties kafka = new KafkaServicesProperties();
+ private ProjectreactorProperties projectreactor = new ProjectreactorProperties();
@Getter
private String haproxyMap = "/usr/local/etc/haproxy/sharding.map";
}
+ @Getter
+ @Setter
+ public static class ProjectreactorProperties
+ {
+ private Level loggingLevel = Level.FINE;
+ private boolean showOperatorLine = true;
+ }
public enum ServiceType { inmemory, kafka }
public enum StorageStrategyType { none, files, mongodb }
public enum ShardingStrategyType { none, kafkalike }
package de.juplo.kafka.chat.backend.api;
+import de.juplo.kafka.chat.backend.ChatBackendProperties;
import de.juplo.kafka.chat.backend.domain.ChatHomeService;
import de.juplo.kafka.chat.backend.domain.ChatRoomData;
import de.juplo.kafka.chat.backend.implementation.StorageStrategy;
-import lombok.RequiredArgsConstructor;
import org.springframework.http.codec.ServerSentEvent;
import org.springframework.web.bind.annotation.*;
import reactor.core.publisher.Flux;
@RestController
-@RequiredArgsConstructor
public class ChatBackendController
{
private final ChatHomeService chatHomeService;
private final StorageStrategy storageStrategy;
+ private final Level loggingLevel;
+ private final boolean showOperatorLine;
+
+
+ public ChatBackendController(
+ ChatHomeService chatHomeService,
+ StorageStrategy storageStrategy,
+ ChatBackendProperties properties)
+ {
+ this.chatHomeService = chatHomeService;
+ this.storageStrategy = storageStrategy;
+ this.loggingLevel = properties.getProjectreactor().getLoggingLevel();
+ this.showOperatorLine = properties.getProjectreactor().isShowOperatorLine();
+ }
@PostMapping("create")
.listen()
.log(
ChatBackendController.class.getSimpleName(),
- Level.FINE,
- true)
+ loggingLevel,
+ showOperatorLine)
.map(message -> MessageTo.from(message))
.map(messageTo ->
ServerSentEvent
return new FilesStorageStrategy(
Paths.get(properties.getInmemory().getStorageDirectory()),
shardingStrategy,
- mapper);
+ mapper,
+ properties.getProjectreactor().getLoggingLevel(),
+ properties.getProjectreactor().isShowOperatorLine());
}
}
private final Path storagePath;
private final ShardingStrategy shardingStrategy;
private final ObjectMapper mapper;
+ private final Level loggingLevel;
+ private final boolean showOperatorLine;
@Override
return chatRoomInfoFlux
.log(
FilesStorageStrategy.class.getSimpleName(),
- Level.FINE,
- true)
+ loggingLevel,
+ showOperatorLine)
.doFirst(() ->
{
try
.from(new JsonFilePublisher<ChatRoomInfoTo>(chatroomsPath(), mapper, type))
.log(
FilesStorageStrategy.class.getSimpleName(),
- Level.FINE,
- true)
+ loggingLevel,
+ showOperatorLine)
.map(chatRoomInfoTo ->
{
UUID chatRoomId = chatRoomInfoTo.getId();
return messageFlux
.log(
FilesStorageStrategy.class.getSimpleName(),
- Level.FINE,
- true)
+ loggingLevel,
+ showOperatorLine)
.doFirst(() ->
{
try
.from(new JsonFilePublisher<MessageTo>(chatroomPath(chatRoomId), mapper, type))
.log(
FilesStorageStrategy.class.getSimpleName(),
- Level.FINE,
- true)
+ loggingLevel,
+ showOperatorLine)
.map(MessageTo::toMessage);
}
import java.nio.file.Path;
import java.nio.file.Paths;
import java.time.Clock;
+import java.util.logging.Level;
@Slf4j
storageStrategy = new FilesStorageStrategy(
path,
chatRoomId -> 0,
- mapper);
+ mapper,
+ Level.FINE,
+ true);
}
import java.net.URI;
import java.nio.file.Paths;
import java.time.Clock;
+import java.util.logging.Level;
import java.util.stream.IntStream;
public class ShardedChatHomeServiceTest extends ChatHomeServiceWithShardsTest
return new FilesStorageStrategy(
Paths.get("target", "test-classes", "data", "files"),
new KafkaLikeShardingStrategy(NUM_SHARDS),
- objectMapper);
+ objectMapper,
+ Level.FINE,
+ true);
}
@Bean
import java.nio.file.Paths;
import java.time.Clock;
+import java.util.logging.Level;
public class SimpleChatHomeServiceTest extends ChatHomeServiceTest
return new FilesStorageStrategy(
Paths.get("target", "test-classes", "data", "files"),
chatRoomId -> 0,
- objectMapper);
+ objectMapper,
+ Level.FINE,
+ true);
}
@Bean