@SpringBootApplication
public class ChatBackendApplication
{
- @Bean
- public Clock clock()
- {
- return Clock.systemDefaultZone();
- }
-
-
public static void main(String[] args)
{
SpringApplication.run(ChatBackendApplication.class, args);
--- /dev/null
+package de.juplo.kafka.chat.backend;
+
+import de.juplo.kafka.chat.backend.domain.ChatroomFactory;
+import de.juplo.kafka.chat.backend.persistence.InMemoryChatroomFactory;
+import de.juplo.kafka.chat.backend.persistence.InMemoryPersistenceStrategy;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import java.time.Clock;
+
+
+@Configuration
+public class ChatBackendConfiguration
+{
+ @Bean
+ ChatroomFactory chatroomFactory(InMemoryPersistenceStrategy persistenceStrategy)
+ {
+ return new InMemoryChatroomFactory(persistenceStrategy);
+ }
+
+ @Bean
+ InMemoryPersistenceStrategy persistenceStrategy()
+ {
+ return new InMemoryPersistenceStrategy();
+ }
+
+ @Bean
+ public Clock clock()
+ {
+ return Clock.systemDefaultZone();
+ }
+}
import de.juplo.kafka.chat.backend.domain.ChatroomFactory;
import de.juplo.kafka.chat.backend.domain.PersistenceStrategy;
import lombok.RequiredArgsConstructor;
-import org.springframework.stereotype.Component;
import java.util.UUID;
-@Component
@RequiredArgsConstructor
public class InMemoryChatroomFactory implements ChatroomFactory
{
import de.juplo.kafka.chat.backend.domain.Message;
import de.juplo.kafka.chat.backend.domain.MessageMutationException;
import de.juplo.kafka.chat.backend.domain.PersistenceStrategy;
-import lombok.Getter;
import lombok.RequiredArgsConstructor;
-import lombok.Value;
import lombok.extern.slf4j.Slf4j;
-import org.springframework.stereotype.Component;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
-import reactor.core.publisher.Sinks;
import java.time.LocalDateTime;
import java.util.LinkedHashMap;
-import java.util.UUID;
-import java.util.stream.Stream;
-@Component
@RequiredArgsConstructor
@Slf4j
public class InMemoryPersistenceStrategy implements PersistenceStrategy