Skip to content

Commit

Permalink
graphman: deduplicate deployment locator for pause and resume (#5674)
Browse files Browse the repository at this point in the history
  • Loading branch information
isum authored Oct 18, 2024
1 parent 1642eaf commit 415005f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
5 changes: 2 additions & 3 deletions core/graphman/src/commands/deployment/pause.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,11 @@ pub fn load_active_deployment(
) -> Result<ActiveDeployment, PauseDeploymentError> {
let mut primary_conn = primary_pool.get().map_err(GraphmanError::from)?;

let locator = crate::deployment::load_deployment(
let locator = crate::deployment::load_deployment_locator(
&mut primary_conn,
deployment,
&DeploymentVersionSelector::All,
)?
.locator();
)?;

let mut catalog_conn = catalog::Connection::new(primary_conn);

Expand Down
5 changes: 2 additions & 3 deletions core/graphman/src/commands/deployment/resume.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,11 @@ pub fn load_paused_deployment(
) -> Result<PausedDeployment, ResumeDeploymentError> {
let mut primary_conn = primary_pool.get().map_err(GraphmanError::from)?;

let locator = crate::deployment::load_deployment(
let locator = crate::deployment::load_deployment_locator(
&mut primary_conn,
deployment,
&DeploymentVersionSelector::All,
)?
.locator();
)?;

let mut catalog_conn = catalog::Connection::new(primary_conn);

Expand Down
10 changes: 6 additions & 4 deletions core/graphman/src/deployment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,15 @@ pub(crate) fn load_deployments(
query.load(primary_conn).map_err(Into::into)
}

pub(crate) fn load_deployment(
pub(crate) fn load_deployment_locator(
primary_conn: &mut PgConnection,
deployment: &DeploymentSelector,
version: &DeploymentVersionSelector,
) -> Result<Deployment, GraphmanError> {
let deployment = load_deployments(primary_conn, deployment, version)?
) -> Result<DeploymentLocator, GraphmanError> {
let deployment_locator = load_deployments(primary_conn, deployment, version)?
.into_iter()
.map(|deployment| deployment.locator())
.unique()
.exactly_one()
.map_err(|err| {
let count = err.into_iter().count();
Expand All @@ -142,5 +144,5 @@ pub(crate) fn load_deployment(
))
})?;

Ok(deployment)
Ok(deployment_locator)
}

0 comments on commit 415005f

Please sign in to comment.