Skip to content

Commit 8e11d1f

Browse files
committed
store: Asyncify details
1 parent 13d8c42 commit 8e11d1f

File tree

3 files changed

+14
-13
lines changed

3 files changed

+14
-13
lines changed

store/postgres/src/deployment.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1227,7 +1227,7 @@ pub async fn create_deployment(
12271227
d::debug_fork.eq(debug_fork.as_ref().map(|s| s.as_str())),
12281228
);
12291229

1230-
let graph_node_version_id = GraphNodeVersion::create_or_get(conn)?;
1230+
let graph_node_version_id = GraphNodeVersion::create_or_get(conn).await?;
12311231

12321232
let manifest_values = (
12331233
m::id.eq(site.id),

store/postgres/src/deployment_store.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ impl DeploymentStore {
267267
let layout = self.layout(&mut conn, site.clone()).await?;
268268
Ok(
269269
detail::deployment_entity(&mut conn, &site, &layout.input_schema)
270+
.await
270271
.with_context(|| format!("Deployment details not found for {}", site.deployment))?,
271272
)
272273
}
@@ -551,7 +552,7 @@ impl DeploymentStore {
551552
ids: Vec<String>,
552553
) -> Result<Vec<DeploymentDetail>, StoreError> {
553554
let conn = &mut *self.get_conn().await?;
554-
detail::deployment_details(conn, ids)
555+
detail::deployment_details(conn, ids).await
555556
}
556557

557558
pub async fn deployment_details_for_id(
@@ -560,15 +561,15 @@ impl DeploymentStore {
560561
) -> Result<DeploymentDetail, StoreError> {
561562
let id = DeploymentId::from(locator.clone());
562563
let conn = &mut *self.get_conn().await?;
563-
detail::deployment_details_for_id(conn, &id)
564+
detail::deployment_details_for_id(conn, &id).await
564565
}
565566

566567
pub(crate) async fn deployment_statuses(
567568
&self,
568569
sites: &[Arc<Site>],
569570
) -> Result<Vec<status::Info>, StoreError> {
570571
let conn = &mut *self.get_conn().await?;
571-
detail::deployment_statuses(conn, sites)
572+
detail::deployment_statuses(conn, sites).await
572573
}
573574

574575
pub(crate) async fn deployment_exists_and_synced(
@@ -1005,7 +1006,7 @@ impl DeploymentStore {
10051006
if latest_block_ptr.number < block.number {
10061007
// If a subgraph has failed deterministically then any blocks past head
10071008
// should return the same POI
1008-
let fatal_error = ErrorDetail::fatal(conn, &site.deployment)?;
1009+
let fatal_error = ErrorDetail::fatal(conn, &site.deployment).await?;
10091010
block_ptr = match fatal_error {
10101011
Some(se) => TryInto::<SubgraphError>::try_into(se)?
10111012
.block_ptr
@@ -1732,7 +1733,7 @@ impl DeploymentStore {
17321733
conn.transaction_async(|conn| {
17331734
async {
17341735
// We'll only unfail subgraphs that had fatal errors
1735-
let subgraph_error = match ErrorDetail::fatal(conn, deployment_id)? {
1736+
let subgraph_error = match ErrorDetail::fatal(conn, deployment_id).await? {
17361737
Some(fatal_error) => fatal_error,
17371738
// If the subgraph is not failed then there is nothing to do.
17381739
None => return Ok(UnfailOutcome::Noop),
@@ -1828,7 +1829,7 @@ impl DeploymentStore {
18281829

18291830
conn.transaction_async(|conn| async {
18301831
// We'll only unfail subgraphs that had fatal errors
1831-
let subgraph_error = match ErrorDetail::fatal(conn, deployment_id)? {
1832+
let subgraph_error = match ErrorDetail::fatal(conn, deployment_id).await? {
18321833
Some(fatal_error) => fatal_error,
18331834
// If the subgraph is not failed then there is nothing to do.
18341835
None => return Ok(UnfailOutcome::Noop),

store/postgres/src/detail.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ pub(crate) struct ErrorDetail {
153153
impl ErrorDetail {
154154
/// Fetches the fatal error, if present, associated with the given
155155
/// [`DeploymentHash`].
156-
pub fn fatal(
156+
pub async fn fatal(
157157
conn: &mut PgConnection,
158158
deployment_id: &DeploymentHash,
159159
) -> Result<Option<Self>, StoreError> {
@@ -305,7 +305,7 @@ pub(crate) fn info_from_details(
305305
}
306306

307307
/// Return the details for `deployments`
308-
pub(crate) fn deployment_details(
308+
pub(crate) async fn deployment_details(
309309
conn: &mut PgConnection,
310310
deployments: Vec<String>,
311311
) -> Result<Vec<DeploymentDetail>, StoreError> {
@@ -334,7 +334,7 @@ pub(crate) fn deployment_details(
334334
}
335335

336336
/// Return the details for `deployment`
337-
pub(crate) fn deployment_details_for_id(
337+
pub(crate) async fn deployment_details_for_id(
338338
conn: &mut PgConnection,
339339
deployment: &DeploymentId,
340340
) -> Result<DeploymentDetail, StoreError> {
@@ -352,7 +352,7 @@ pub(crate) fn deployment_details_for_id(
352352
.map(DeploymentDetail::from)
353353
}
354354

355-
pub(crate) fn deployment_statuses(
355+
pub(crate) async fn deployment_statuses(
356356
conn: &mut PgConnection,
357357
sites: &[Arc<Site>],
358358
) -> Result<Vec<status::Info>, StoreError> {
@@ -538,7 +538,7 @@ impl StoredDeploymentEntity {
538538
}
539539
}
540540

541-
pub fn deployment_entity(
541+
pub async fn deployment_entity(
542542
conn: &mut PgConnection,
543543
site: &Site,
544544
schema: &InputSchema,
@@ -575,7 +575,7 @@ pub struct GraphNodeVersion {
575575
}
576576

577577
impl GraphNodeVersion {
578-
pub(crate) fn create_or_get(conn: &mut PgConnection) -> anyhow::Result<i32> {
578+
pub(crate) async fn create_or_get(conn: &mut PgConnection) -> anyhow::Result<i32> {
579579
let git_commit_hash = version_commit_hash!();
580580
let git_repository_dirty = !&TESTAMENT.modifications.is_empty();
581581
let crate_version = CARGO_PKG_VERSION;

0 commit comments

Comments
 (0)