Skip to content

Commit ba422c9

Browse files
committed
node: Add graphman commands to pause and resume subgraphs
1 parent 3e3dc02 commit ba422c9

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

node/src/bin/manager.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,16 @@ pub enum Command {
158158
/// The deployment (see `help info`)
159159
deployment: DeploymentSearch,
160160
},
161+
/// Pause a deployment
162+
Pause {
163+
/// The deployment (see `help info`)
164+
deployment: DeploymentSearch,
165+
},
166+
/// Resume a deployment
167+
Resume {
168+
/// The deployment (see `help info`)
169+
deployment: DeploymentSearch,
170+
},
161171
/// Rewind a subgraph to a specific block
162172
Rewind {
163173
/// Force rewinding even if the block hash is not found in the local
@@ -1101,6 +1111,14 @@ async fn main() -> anyhow::Result<()> {
11011111
let sender = ctx.notification_sender();
11021112
commands::assign::reassign(ctx.primary_pool(), &sender, &deployment, node)
11031113
}
1114+
Pause { deployment } => {
1115+
let sender = ctx.notification_sender();
1116+
commands::assign::pause_or_resume(ctx.primary_pool(), &sender, &deployment, true)
1117+
}
1118+
Resume { deployment } => {
1119+
let sender = ctx.notification_sender();
1120+
commands::assign::pause_or_resume(ctx.primary_pool(), &sender, &deployment, false)
1121+
}
11041122
Rewind {
11051123
force,
11061124
sleep,

node/src/manager/commands/assign.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,31 @@ pub fn reassign(
6969
}
7070
Ok(())
7171
}
72+
73+
pub fn pause_or_resume(
74+
primary: ConnectionPool,
75+
sender: &NotificationSender,
76+
search: &DeploymentSearch,
77+
pause: bool,
78+
) -> Result<(), Error> {
79+
let locator = search.locate_unique(&primary)?;
80+
81+
let conn = primary.get()?;
82+
let conn = catalog::Connection::new(conn);
83+
84+
let site = conn
85+
.locate_site(locator.clone())?
86+
.ok_or_else(|| anyhow!("failed to locate site for {locator}"))?;
87+
88+
if pause {
89+
println!("pausing {locator}");
90+
conn.pause_subgraph(&site)?;
91+
println!("paused {locator}")
92+
} else {
93+
println!("resuming {locator}");
94+
conn.resume_subgraph(&site)?;
95+
println!("resumed {locator}")
96+
}
97+
98+
Ok(())
99+
}

0 commit comments

Comments
 (0)