-
Notifications
You must be signed in to change notification settings - Fork 1k
/
Copy pathreassign.rs
54 lines (49 loc) · 1.49 KB
/
reassign.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
use std::sync::Arc;
use anyhow::Result;
use graph::prelude::NodeId;
use graph_store_postgres::connection_pool::ConnectionPool;
use graph_store_postgres::NotificationSender;
use graphman::commands::deployment::reassign::{
load_deployment, reassign_deployment, ReassignResult,
};
use graphman::deployment::DeploymentSelector;
pub fn run(
primary_pool: ConnectionPool,
notification_sender: Arc<NotificationSender>,
deployment: DeploymentSelector,
node: &NodeId,
) -> Result<()> {
let deployment = load_deployment(primary_pool.clone(), &deployment)?;
let curr_node = deployment.assigned_node(primary_pool.clone())?;
let reassign_msg = match &curr_node {
Some(curr_node) => format!(
"Reassigning deployment {} (was {})",
deployment.locator(),
curr_node
),
None => format!("Reassigning deployment {}", deployment.locator()),
};
println!("{}", reassign_msg);
let reassign_result = reassign_deployment(
primary_pool,
notification_sender,
&deployment,
node,
curr_node,
)?;
match reassign_result {
ReassignResult::EmptyResponse => {
println!(
"Deployment {} assigned to node {}",
deployment.locator(),
node
);
}
ReassignResult::CompletedWithWarnings(warnings) => {
for msg in warnings {
println!("{}", msg);
}
}
}
Ok(())
}