Skip to content

Commit

Permalink
add logging + fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
LeonHartley committed Jan 20, 2024
1 parent b225db4 commit d242790
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
8 changes: 5 additions & 3 deletions coerce/src/remote/cluster/singleton/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ pub struct SingletonBuilder<F: SingletonFactory> {
factory: Option<F>,
singleton_id: Option<ActorId>,
manager_id: Option<ActorId>,
proxy_id: Option<ActorId>,
node_selector: NodeSelector,
system: RemoteActorSystem,
}
Expand All @@ -34,7 +35,8 @@ impl<F: SingletonFactory> SingletonBuilder<F> {
system,
factory: None,
singleton_id: Some(F::Actor::type_name().into_actor_id()),
manager_id: Some(Manager::<F>::type_name().into_actor_id()),
manager_id: Some(format!("singleton-manager<{}>", F::Actor::type_name()).into_actor_id()),
proxy_id: Some(format!("singleton-proxy<{}>", F::Actor::type_name()).into_actor_id()),
node_selector: NodeSelector::All,
}
}
Expand All @@ -49,10 +51,10 @@ impl<F: SingletonFactory> SingletonBuilder<F> {

let node_id = self.system.node_id();
let base_manager_id = self.manager_id.expect("manager actor id");
let base_proxy_id = self.proxy_id.expect("proxy actor id");

let manager_actor_id = format!("{}-{}", &base_manager_id, node_id).to_actor_id();

let proxy_actor_id = format!("{}-{}-proxy", &base_manager_id, node_id).to_actor_id();
let proxy_actor_id = format!("{}-{}", &base_proxy_id, node_id).to_actor_id();

let singleton_actor_id = self.singleton_id.expect("singleton actor id");
let actor_system = self.system.actor_system().clone();
Expand Down
4 changes: 2 additions & 2 deletions coerce/src/remote/cluster/singleton/proxy/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::collections::VecDeque;

pub mod send;

pub enum ProxyState<A> {
pub enum ProxyState<A: Actor> {
Buffered {
request_queue: VecDeque<Box<dyn Buffered<A>>>,
},
Expand Down Expand Up @@ -45,7 +45,7 @@ pub struct SingletonStarted<A: Actor> {

pub struct SingletonStopping {}

impl<A> Message for SingletonStarted<A> {
impl<A: Actor> Message for SingletonStarted<A> {
type Result = ();
}

Expand Down
10 changes: 9 additions & 1 deletion coerce/src/remote/cluster/singleton/proxy/send.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ impl<M: Message> Send<M> {
tokio::spawn(async move {
let res = actor.send(message).await;
match res {
Ok(r) => result_channel.send(r),
Ok(r) => {
let _ = result_channel.send(r);
}
Err(_) => {}
}
});
Expand Down Expand Up @@ -53,10 +55,16 @@ where
match &mut self.state {
ProxyState::Buffered { request_queue } => {
request_queue.push_back(Box::new(message));
debug!(
"singleton proxy buffered message (msg_type={}, total_buffered={})",
M::type_name(),
request_queue.len()
);
}

ProxyState::Active { actor_ref } => {
message.deliver(actor_ref.clone());
debug!("singleton proxy sent message (msg_type={})", M::type_name());
}
}
}
Expand Down

0 comments on commit d242790

Please sign in to comment.