@Bean
public StorageStrategy storageStrategy(
ChatRoomRepository chatRoomRepository,
- MessageRepository messageRepository,
- ShardingStrategy shardingStrategy)
+ MessageRepository messageRepository)
{
- return new MongoDbStorageStrategy(
- chatRoomRepository,
- messageRepository,
- shardingStrategy);
+ return new MongoDbStorageStrategy(chatRoomRepository, messageRepository);
}
}
import de.juplo.kafka.chat.backend.domain.ChatRoomInfo;
import de.juplo.kafka.chat.backend.domain.Message;
-import de.juplo.kafka.chat.backend.implementation.ShardingStrategy;
import de.juplo.kafka.chat.backend.implementation.StorageStrategy;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
{
private final ChatRoomRepository chatRoomRepository;
private final MessageRepository messageRepository;
- private final ShardingStrategy shardingStrategy;
@Override
{
return chatRoomInfoFlux
.map(ChatRoomTo::from)
- .map(chatroomTo -> chatRoomRepository.save(chatroomTo))
+ .map(chatRoomRepository::save)
.map(ChatRoomTo::toChatRoomInfo);
}
{
return Flux
.fromIterable(chatRoomRepository.findAll())
- .map(chatRoomTo ->
- {
- UUID chatRoomId = UUID.fromString(chatRoomTo.getId());
- return new ChatRoomInfo(chatRoomId, chatRoomTo.getName(), null);
- });
+ .map(ChatRoomTo::toChatRoomInfo);
}
@Override
{
return messageFlux
.map(message -> MessageTo.from(chatRoomId, message))
- .map(messageTo -> messageRepository.save(messageTo))
+ .map(messageRepository::save)
.map(MessageTo::toMessage);
}
{
return Flux
.fromIterable(messageRepository.findByChatRoomIdOrderBySerialAsc(chatRoomId.toString()))
- .map(messageTo -> messageTo.toMessage());
+ .map(MessageTo::toMessage);
}
}
@Bean
MongoDbStorageStrategy storageStrategy(
ChatRoomRepository chatRoomRepository,
- MessageRepository messageRepository,
- Clock clock)
+ MessageRepository messageRepository)
{
- return new MongoDbStorageStrategy(
- chatRoomRepository,
- messageRepository,
- chatRoomId -> 0);
+ return new MongoDbStorageStrategy(chatRoomRepository, messageRepository);
}
@Bean
@Container
private static final GenericContainer CONTAINER =
- new GenericContainer("mongo:6")
- .withExposedPorts(MONGODB_PORT);
+ new GenericContainer("mongo:6").withExposedPorts(MONGODB_PORT);
public static class DataSourceInitializer
implements ApplicationContextInitializer<ConfigurableApplicationContext>