Skip to content

Commit

Permalink
ensure singleton managers have unique actor IDs
Browse files Browse the repository at this point in the history
  • Loading branch information
LeonHartley committed Jan 10, 2024
1 parent bf2957b commit a4fe7af
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
6 changes: 3 additions & 3 deletions coerce/src/remote/cluster/singleton/manager/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -259,7 +259,7 @@ impl<F: SingletonFactory> Handler<Receive<SystemTopic>> for Manager<F> {
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(),
)
Expand All @@ -281,7 +281,7 @@ impl<F: SingletonFactory> Handler<Receive<SystemTopic>> for Manager<F> {
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(),
)
Expand Down
9 changes: 4 additions & 5 deletions coerce/src/remote/cluster/singleton/mod.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down Expand Up @@ -43,14 +41,15 @@ impl<F: SingletonFactory> SingletonBuilder<F> {

pub async fn build(mut self) -> Singleton<F::Actor, F> {
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,
)
Expand Down

0 comments on commit a4fe7af

Please sign in to comment.