akka/akka-core

Cluster sharding: Expose entity ID to the sharded actor

オープン

#24,053 opened on 2017/11/23

 (17 件のコメント) (1 件のリアクション) (0 人の担当者)Scala (3,547 件のフォーク)batch import
help wantednice-to-have (low-prio)t:cluster-sharding

Repository metrics

Stars
 (13,277 個のスター)
PR merge metrics
 (平均マージ 8d 19h) (30d で 10 merged PRs)

説明

Apologies in advance if this issue was brought up in the past. I tried to search for it, but couldn't find anything...

Currently, sharded actors don't have access to their entity identifier. The example in the docs uses self.path.name, but that is URL-encoded and not the actual ID. On top of that, this seems to be an implementation detail - the encoded ID happens to be what the shard uses for the actor name. At the same time, it is obvious that adding an Actor.entityId method is not a good solution (actors don't know whether or not they're sharded).

So I suggest modifying the ClusterSharding.start (or adding another API next to it) so that instead of taking Props as a parameter, it would take a String => Props function that would get invoked with the entity ID. What do you think?

(Of course, I wouldn't mind doing a PR for it, if there's interest)

コントリビューターガイド