refactor: Pulled business-logic into class `ShardedChatHome`
authorKai Moritz <kai@juplo.de>
Sat, 14 Jan 2023 15:47:04 +0000 (16:47 +0100)
committerKai Moritz <kai@juplo.de>
Sun, 15 Jan 2023 18:39:01 +0000 (19:39 +0100)
commit47c05f0a8a59bba36c7de4bc344c4fb416b649f4
tree996eecd3ab42a16a6b78df9648ca15420936e6c3
parentc1d3ca2a54bd62e0e7cf631716cdc7bfbeb22d38
refactor: Pulled business-logic into class `ShardedChatHome`

- Pulled the logic that selects the appropriate shard from the class
  `ChatBackendController` into the newly introduced class
  `ShardedChatHome`.
- Simplified the configuration
  - `InMemoryServicesConfiguration` creates a `ChatHome` of type
    `SimpleChatHome`, if the `sharding-strategy` `none` is choosen.
  - In that case, the values for `num-shards` and `owned-shards` are
    ignored and set to `1` and `0`.
  - If the `sharding-strategy` is set to `kafkalike`, a `ChatHome` of
    type `ShardedChatHome` is instanciated and the configuration
    respects the configured sharding.
- Simplified the configuration of `ChatBackendControllerTest` accordingly.
19 files changed:
src/main/java/de/juplo/kafka/chat/backend/api/ChatBackendController.java
src/main/java/de/juplo/kafka/chat/backend/api/KafkaLikeShardingStrategy.java [deleted file]
src/main/java/de/juplo/kafka/chat/backend/api/ShardingStrategy.java [deleted file]
src/main/java/de/juplo/kafka/chat/backend/domain/ShardedChatHome.java [new file with mode: 0644]
src/main/java/de/juplo/kafka/chat/backend/domain/ShardingStrategy.java [new file with mode: 0644]
src/main/java/de/juplo/kafka/chat/backend/domain/SimpleChatHome.java
src/main/java/de/juplo/kafka/chat/backend/persistence/KafkaLikeShardingStrategy.java [new file with mode: 0644]
src/main/java/de/juplo/kafka/chat/backend/persistence/inmemory/InMemoryChatRoomFactory.java
src/main/java/de/juplo/kafka/chat/backend/persistence/inmemory/InMemoryServicesConfiguration.java
src/main/java/de/juplo/kafka/chat/backend/persistence/storage/files/FilesStorageConfiguration.java
src/main/java/de/juplo/kafka/chat/backend/persistence/storage/files/FilesStorageStrategy.java
src/main/java/de/juplo/kafka/chat/backend/persistence/storage/mongodb/MongoDbStorageConfiguration.java
src/main/java/de/juplo/kafka/chat/backend/persistence/storage/mongodb/MongoDbStorageStrategy.java
src/test/java/de/juplo/kafka/chat/backend/InMemoryWithFilesConfigurationIT.java
src/test/java/de/juplo/kafka/chat/backend/api/ChatBackendControllerTest.java
src/test/java/de/juplo/kafka/chat/backend/domain/SimpleChatHomeTest.java
src/test/java/de/juplo/kafka/chat/backend/persistence/AbstractStorageStrategyIT.java
src/test/java/de/juplo/kafka/chat/backend/persistence/InMemoryWithFilesStorageIT.java
src/test/java/de/juplo/kafka/chat/backend/persistence/InMemoryWithMongoDbStorageIT.java