projects
/
demos
/
kafka
/
chat
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
feat: Reintroduced `ChatRoom.shard`, becaus it is needed as a routing-hint
[demos/kafka/chat]
/
src
/
main
/
java
/
de
/
juplo
/
kafka
/
chat
/
backend
/
persistence
/
inmemory
/
InMemoryServicesConfiguration.java
diff --git
a/src/main/java/de/juplo/kafka/chat/backend/persistence/inmemory/InMemoryServicesConfiguration.java
b/src/main/java/de/juplo/kafka/chat/backend/persistence/inmemory/InMemoryServicesConfiguration.java
index
1dca040
..
96ef05c
100644
(file)
--- a/
src/main/java/de/juplo/kafka/chat/backend/persistence/inmemory/InMemoryServicesConfiguration.java
+++ b/
src/main/java/de/juplo/kafka/chat/backend/persistence/inmemory/InMemoryServicesConfiguration.java
@@
-45,23
+45,22
@@
public class InMemoryServicesConfiguration
StorageStrategy storageStrategy)
{
int numShards = properties.getInmemory().getNumShards();
StorageStrategy storageStrategy)
{
int numShards = properties.getInmemory().getNumShards();
- ShardingStrategy shardingStrategy = new KafkaLikeShardingStrategy(numShards);
SimpleChatHome[] chatHomes = new SimpleChatHome[numShards];
storageStrategy
.read()
.subscribe(chatRoom ->
{
SimpleChatHome[] chatHomes = new SimpleChatHome[numShards];
storageStrategy
.read()
.subscribe(chatRoom ->
{
- int shard =
shardingStrategy.selectShard(chatRoom.getId()
);
+ int shard =
chatRoom.getShard(
);
if (chatHomes[shard] == null)
chatHomes[shard] = new SimpleChatHome(chatHomeService, shard);
});
if (chatHomes[shard] == null)
chatHomes[shard] = new SimpleChatHome(chatHomeService, shard);
});
- return new ShardedChatHome(chatHomes, shardingStrategy);
+ ShardingStrategy strategy = new KafkaLikeShardingStrategy(numShards);
+ return new ShardedChatHome(chatHomes, strategy);
}
@Bean
InMemoryChatHomeService chatHomeService(
ChatBackendProperties properties,
}
@Bean
InMemoryChatHomeService chatHomeService(
ChatBackendProperties properties,
- ShardingStrategy shardingStrategy,
StorageStrategy storageStrategy)
{
ShardingStrategyType sharding =
StorageStrategy storageStrategy)
{
ShardingStrategyType sharding =
@@
-73,7
+72,6
@@
public class InMemoryServicesConfiguration
? new int[] { 0 }
: properties.getInmemory().getOwnedShards();
return new InMemoryChatHomeService(
? new int[] { 0 }
: properties.getInmemory().getOwnedShards();
return new InMemoryChatHomeService(
- shardingStrategy,
numShards,
ownedShards,
storageStrategy.read());
numShards,
ownedShards,
storageStrategy.read());