Can we obtain the Cluster.Member from an ActorRef?

Given an ActorRef received from a message, can we determine the Cluster.Member?


If I remember correctly, and using the classic API (though it should also work with the typed one):

val reference = // some ActorRef
val cluster = Cluster(system)
val member: Option[Member] = cluster.state.members.find { member =>
      member.address == reference.path.address

@manuelbernhardt Thank you.

Note that Address in a path can be local (no host/port) if the ActorRef is local so you’ll need special handling for that, you can check hasLocalScope and then use Cluster#selfMember#address for that case.

@johanandren I was under the impression that the address path would always have a host and port. I also assumed a local host would have the local IP set. Thanks for the warning.