[英]Implement one actor per user (Child-Per-Entity pattern) in a cluster using Akka.NET
I'm doing a little sample to learn a bit about Akka.NET. 我正在做一些示例以了解有关Akka.NET的知识。 I'm trying to implement a Child-Per-Entity pattern (as seen in Akka.NET Design Patterns ), where I have one actor per user (across a cluster). 我正在尝试实现“每个实体的孩子”模式(如Akka.NET设计模式所示 ),其中每个用户(在整个集群中)每个角色都有一个参与者 。
To do this I was trying to use a ClusterRouterPool with ConsistentHashingPool, that distributed the messages to some parent actors that kept an IDictionary(int,IActorRef) with the child actors indexed by their id (used as the key for the consistent hash). 为此,我尝试使用带有ConsistentHashingPool的ClusterRouterPool,该消息将消息分发给一些父角色,该父角色保留IDictionary(int,IActorRef)并通过其ID索引子角色(用作一致性哈希的键)。
This approach however doesn't seem to be working as I initially expected because: 但是,这种方法似乎并不像我最初预期的那样起作用,因为:
There's a somewhat similar question here on StackOverflow that points to using Akka.Cluster.Sharding, but on Akka.NET Design Patterns Aaron has a comment stating he used the consistent hash router approach, hence why I started it in the first place. 在StackOverflow上有一个类似的问题 ,它指向使用Akka.Cluster.Sharding,但是在Akka.NET设计模式上, Aaron发表了一条评论,指出他使用了一致的哈希路由器方法,因此为什么我首先开始使用它。
Thanks 谢谢
I think, that key concept is to understand a difference between Akka.Cluster.Sharding and consistent hash router: 我认为,这个关键概念是要了解Akka.Cluster.Sharding和一致的哈希路由器之间的区别:
Therefore I think, that cluster sharding is what you're looking for. 因此,我认为您正在寻找集群分片。 Inside examples section of Akka.NET core repository you may find a sample which addresses your case directly. 在Akka.NET核心存储库的“示例”部分中,您可能会找到一个直接解决您的案例的示例 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.