+ ChatBackendProperties properties,
+ StorageStrategy storageStrategy)
+ {
+ ShardingStrategyType sharding =
+ properties.getInmemory().getShardingStrategy();
+
+ int numShards;
+ int[] ownedShards;
+ ShardingStrategy shardingStrategy;
+
+ switch (sharding)
+ {
+ case none:
+ numShards = 1;
+ ownedShards = new int[] { 0 };
+ shardingStrategy = id -> 0;
+ break;
+ case kafkalike:
+ numShards = properties.getInmemory().getNumShards();
+ ownedShards = properties.getInmemory().getOwnedShards();
+ shardingStrategy = new KafkaLikeShardingStrategy(numShards);
+ break;
+ default:
+ throw new IllegalArgumentException("Unknown sharding strategy: " + sharding);
+ }
+
+ return new InMemoryChatHomeService(
+ numShards,
+ ownedShards,
+ shardingStrategy,
+ storageStrategy.read());
+ }
+
+ @Bean
+ InMemoryChatRoomFactory chatRoomFactory(
+ InMemoryChatHomeService service,
+ ShardingStrategy strategy,