From a4fe7af7ac7e0c689c421b2f85134624daa71e94 Mon Sep 17 00:00:00 2001 From: Leon Hartley Date: Wed, 10 Jan 2024 20:43:31 +0000 Subject: [PATCH] ensure singleton managers have unique actor IDs --- coerce/src/remote/cluster/singleton/manager/mod.rs | 6 +++--- coerce/src/remote/cluster/singleton/mod.rs | 9 ++++----- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/coerce/src/remote/cluster/singleton/manager/mod.rs b/coerce/src/remote/cluster/singleton/manager/mod.rs index 744ae71..60e0bf4 100644 --- a/coerce/src/remote/cluster/singleton/manager/mod.rs +++ b/coerce/src/remote/cluster/singleton/manager/mod.rs @@ -4,7 +4,7 @@ mod status; use crate::actor::context::ActorContext; use crate::actor::message::{Handler, Message}; -use crate::actor::{Actor, ActorFactory, ActorId, ActorRef, ActorRefErr, IntoActor, LocalActorRef}; +use crate::actor::{Actor, ActorFactory, ActorId, ActorRef, ActorRefErr, IntoActor, LocalActorRef, ToActorId}; use crate::remote::cluster::node::NodeSelector; use crate::remote::cluster::singleton::factory::SingletonFactory; use crate::remote::stream::pubsub::{PubSub, Receive, Subscription}; @@ -259,7 +259,7 @@ impl Handler> for Manager { self.managers.insert( node.id, RemoteActorRef::new( - self.manager_actor_id.clone(), + format!("{}-{}", &self.manager_actor_id, node.id).to_actor_id(), node.id, sys.clone(), ) @@ -281,7 +281,7 @@ impl Handler> for Manager { let mut entry = self.managers.entry(node.id); if let Entry::Vacant(mut entry) = entry { let remote_ref = RemoteActorRef::new( - self.manager_actor_id.clone(), + format!("{}-{}", &self.manager_actor_id, node.id).to_actor_id(), node.id, sys.clone(), ) diff --git a/coerce/src/remote/cluster/singleton/mod.rs b/coerce/src/remote/cluster/singleton/mod.rs index c9949c7..9e0fbb4 100644 --- a/coerce/src/remote/cluster/singleton/mod.rs +++ b/coerce/src/remote/cluster/singleton/mod.rs @@ -1,7 +1,5 @@ use crate::actor::message::{Handler, Message}; -use crate::actor::{ - Actor, ActorFactory, ActorId, ActorRefErr, IntoActor, IntoActorId, LocalActorRef, -}; +use crate::actor::{Actor, ActorFactory, ActorId, ActorRefErr, IntoActor, IntoActorId, LocalActorRef, ToActorId}; use crate::remote::cluster::node::NodeSelector; use crate::remote::cluster::singleton::factory::SingletonFactory; use crate::remote::cluster::singleton::manager::lease::{LeaseAck, RequestLease}; @@ -43,14 +41,15 @@ impl SingletonBuilder { pub async fn build(mut self) -> Singleton { let factory = self.factory.expect("factory"); - let manager_actor_id = self.manager_id.expect("manager actor id"); + let base_manager_id = self.manager_id.expect("manager actor id"); + let manager_actor_id = format!("{}-{}", &base_manager_id, self.system.node_id()).to_actor_id(); let singleton_actor_id = self.singleton_id.expect("singleton actor id"); let actor_system = self.system.actor_system().clone(); let manager = Manager::new( self.system, factory, - manager_actor_id.clone(), + base_manager_id, singleton_actor_id, self.node_selector, )