Skip to content

Commit

Permalink
ctl: display response message for successful ProxyRequestOrder
Browse files Browse the repository at this point in the history
  • Loading branch information
Keksoj committed Oct 25, 2022
1 parent 68e3859 commit e90cc52
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 22 deletions.
2 changes: 1 addition & 1 deletion bin/src/command/mod.rs
Expand Up @@ -200,7 +200,7 @@ impl std::fmt::Display for Success {
Some(worker_id) => {
write!(f, "Successfully executed the order on worker {}", worker_id)
}
None => write!(f, "Successfully executed the order on worker"),
None => write!(f, "Successfully executed the order on all workers"),
},
Self::WorkerResponse => write!(f, "Successfully handled worker response"),
Self::WorkerRestarted(id) => write!(f, "Successfully restarted worker {}", id),
Expand Down
8 changes: 5 additions & 3 deletions bin/src/command/orders.rs
Expand Up @@ -806,8 +806,7 @@ impl CommandServer {
let mut found = false;
let id = format!(
"LOAD-STATE-{}-{}",
&request_identifier.request,
diff_counter
&request_identifier.request, diff_counter
);

for ref mut worker in self.workers.iter_mut().filter(|worker| {
Expand Down Expand Up @@ -1268,7 +1267,10 @@ impl CommandServer {
return_processing(
self.command_tx.clone(),
request_identifier.clone(),
"Sending the order to the worker...",
match worker_id {
Some(id) => format!("Sending the order to worker {}", id),
None => "Sending the order to all workers".to_owned(),
},
)
.await;

Expand Down
22 changes: 4 additions & 18 deletions bin/src/ctl/command.rs
Expand Up @@ -749,7 +749,9 @@ impl CommandManager {
pub fn order_command(&mut self, order: ProxyRequestOrder) -> Result<(), anyhow::Error> {
let id = generate_id();

self.send_request(&id, CommandRequestOrder::Proxy(Box::new(order)))?;
let request_order = CommandRequestOrder::Proxy(Box::new(order));
println!("Sending request order: {:?}", request_order);
self.send_request(&id, request_order)?;

loop {
let response = self.read_channel_message_with_timeout()?;
Expand All @@ -761,24 +763,8 @@ impl CommandManager {
CommandStatus::Processing => println!("Proxy is processing: {}", response.message),
CommandStatus::Error => bail!("could not execute order: {}", response.message),
CommandStatus::Ok => {
println!("Success (but nothing to print)");
println!("Success: {}", response.message);
break;
// TODO: reactivate success messages
/*
match order {
ProxyRequestOrder::AddCluster(_) => println!("cluster added : {}", message.message),
ProxyRequestOrder::RemoveCluster(_) => println!("cluster removed : {} ", message.message),
ProxyRequestOrder::AddBackend(_) => println!("backend added : {}", message.message),
ProxyRequestOrder::RemoveBackend(_) => println!("backend removed : {} ", message.message),
ProxyRequestOrder::AddCertificate(_) => println!("certificate added: {}", message.message),
ProxyRequestOrder::RemoveCertificate(_) => println!("certificate removed: {}", message.message),
ProxyRequestOrder::AddHttpFrontend(_) => println!("front added: {}", message.message),
ProxyRequestOrder::RemoveHttpFrontend(_) => println!("front removed: {}", message.message),
_ => {
// do nothing for now
}
}
*/
}
}
}
Expand Down

0 comments on commit e90cc52

Please sign in to comment.