Skip to content

Commit 13d8c42

Browse files
committed
store: Asyncify remaining methods in deployment
1 parent 564472c commit 13d8c42

File tree

3 files changed

+15
-14
lines changed

3 files changed

+15
-14
lines changed

store/postgres/src/deployment.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -860,12 +860,12 @@ pub async fn fail(
860860
) -> Result<(), StoreError> {
861861
let error_id = insert_subgraph_error(conn, error).await?;
862862

863-
update_deployment_status(conn, id, SubgraphHealth::Failed, Some(error_id), None)?;
863+
update_deployment_status(conn, id, SubgraphHealth::Failed, Some(error_id), None).await?;
864864

865865
Ok(())
866866
}
867867

868-
pub fn update_non_fatal_errors(
868+
pub async fn update_non_fatal_errors(
869869
conn: &mut PgConnection,
870870
deployment_id: &DeploymentHash,
871871
health: SubgraphHealth,
@@ -882,13 +882,13 @@ pub fn update_non_fatal_errors(
882882
.collect::<Vec<_>>()
883883
});
884884

885-
update_deployment_status(conn, deployment_id, health, None, error_ids)?;
885+
update_deployment_status(conn, deployment_id, health, None, error_ids).await?;
886886

887887
Ok(())
888888
}
889889

890890
/// If `block` is `None`, assumes the latest block.
891-
pub(crate) fn has_deterministic_errors(
891+
pub(crate) async fn has_deterministic_errors(
892892
conn: &mut PgConnection,
893893
id: &DeploymentHash,
894894
block: BlockNumber,
@@ -904,7 +904,7 @@ pub(crate) fn has_deterministic_errors(
904904
.map_err(|e| e.into())
905905
}
906906

907-
pub fn update_deployment_status(
907+
pub async fn update_deployment_status(
908908
conn: &mut PgConnection,
909909
deployment_id: &DeploymentHash,
910910
health: SubgraphHealth,
@@ -973,7 +973,7 @@ async fn check_health(
973973
) -> Result<(), StoreError> {
974974
use deployment as d;
975975

976-
let has_errors = has_deterministic_errors(conn, id, block)?;
976+
let has_errors = has_deterministic_errors(conn, id, block).await?;
977977

978978
let (new, old) = match has_errors {
979979
true => {
@@ -999,7 +999,7 @@ async fn check_health(
999999
.map_err(|e| e.into())
10001000
}
10011001

1002-
pub(crate) fn health(
1002+
pub(crate) async fn health(
10031003
conn: &mut PgConnection,
10041004
id: DeploymentId,
10051005
) -> Result<SubgraphHealth, StoreError> {
@@ -1012,7 +1012,7 @@ pub(crate) fn health(
10121012
.map_err(|e| e.into())
10131013
}
10141014

1015-
pub(crate) fn entities_with_causality_region(
1015+
pub(crate) async fn entities_with_causality_region(
10161016
conn: &mut PgConnection,
10171017
id: DeploymentId,
10181018
schema: &InputSchema,

store/postgres/src/deployment_store.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1201,7 +1201,8 @@ impl DeploymentStore {
12011201
&site.deployment,
12021202
deployment::SubgraphHealth::Unhealthy,
12031203
Some(&batch.deterministic_errors),
1204-
)?;
1204+
)
1205+
.await?;
12051206
}
12061207
}
12071208

@@ -1745,7 +1746,7 @@ impl DeploymentStore {
17451746
use deployment::SubgraphHealth::*;
17461747
// Decide status based on if there are any errors for the previous/parent block
17471748
let prev_health =
1748-
if deployment::has_deterministic_errors(conn, deployment_id, parent_ptr.number)? {
1749+
if deployment::has_deterministic_errors(conn, deployment_id, parent_ptr.number).await? {
17491750
Unhealthy
17501751
} else {
17511752
Healthy
@@ -1774,7 +1775,7 @@ impl DeploymentStore {
17741775
let _ = self.revert_block_operations(site.clone(), parent_ptr.clone(), &FirehoseCursor::None).await?;
17751776

17761777
// Unfail the deployment.
1777-
deployment::update_deployment_status(conn, deployment_id, prev_health, None,None)?;
1778+
deployment::update_deployment_status(conn, deployment_id, prev_health, None,None).await?;
17781779

17791780
Ok(UnfailOutcome::Unfailed)
17801781
}
@@ -1858,7 +1859,7 @@ impl DeploymentStore {
18581859
deployment::SubgraphHealth::Healthy,
18591860
None,
18601861
None,
1861-
)?;
1862+
).await?;
18621863

18631864
// Delete the fatal error.
18641865
deployment::delete_error(conn, &subgraph_error.id).await?;
@@ -1931,7 +1932,7 @@ impl DeploymentStore {
19311932
site: &Site,
19321933
) -> Result<deployment::SubgraphHealth, StoreError> {
19331934
let id = site.id;
1934-
self.with_conn(async move |conn, _| deployment::health(conn, id).map_err(Into::into))
1935+
self.with_conn(async move |conn, _| deployment::health(conn, id).await.map_err(Into::into))
19351936
.await
19361937
}
19371938

store/postgres/src/relational.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1767,7 +1767,7 @@ impl LayoutCache {
17671767
async fn load(conn: &mut PgConnection, site: Arc<Site>) -> Result<Arc<Layout>, StoreError> {
17681768
let (subgraph_schema, use_bytea_prefix) = deployment::schema(conn, site.as_ref()).await?;
17691769
let has_causality_region =
1770-
deployment::entities_with_causality_region(conn, site.id, &subgraph_schema)?;
1770+
deployment::entities_with_causality_region(conn, site.id, &subgraph_schema).await?;
17711771
let catalog =
17721772
Catalog::load(conn, site.clone(), use_bytea_prefix, has_causality_region).await?;
17731773
let layout = Arc::new(Layout::new(site.clone(), &subgraph_schema, catalog)?);

0 commit comments

Comments
 (0)