Skip to content

Commit 662560b

Browse files
committed
store: Replace uses of Pool.get_sync with Pool.get
1 parent a55acf1 commit 662560b

File tree

5 files changed

+24
-17
lines changed

5 files changed

+24
-17
lines changed

core/graphman/src/commands/deployment/info.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ pub async fn load_deployments(
3131
deployment: &DeploymentSelector,
3232
version: &DeploymentVersionSelector,
3333
) -> Result<Vec<Deployment>, GraphmanError> {
34-
let mut primary_conn = primary_pool.get_sync().await?;
34+
let mut primary_conn = primary_pool.get().await?;
3535

3636
crate::deployment::load_deployments(&mut primary_conn, &deployment, &version).await
3737
}

store/postgres/src/graphman/mod.rs

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use anyhow::Result;
22
use async_trait::async_trait;
33
use chrono::Utc;
44
use diesel::prelude::*;
5+
use diesel_async::RunQueryDsl;
56
use graphman_store::CommandKind;
67
use graphman_store::Execution;
78
use graphman_store::ExecutionId;
@@ -27,7 +28,7 @@ impl GraphmanStore {
2728
#[async_trait]
2829
impl graphman_store::GraphmanStore for GraphmanStore {
2930
async fn new_execution(&self, kind: CommandKind) -> Result<ExecutionId> {
30-
let mut conn = self.primary_pool.get_sync().await?;
31+
let mut conn = self.primary_pool.get().await?;
3132

3233
let id: i64 = diesel::insert_into(gce::table)
3334
.values((
@@ -36,20 +37,21 @@ impl graphman_store::GraphmanStore for GraphmanStore {
3637
gce::created_at.eq(Utc::now()),
3738
))
3839
.returning(gce::id)
39-
.get_result(&mut conn)?;
40+
.get_result(&mut conn)
41+
.await?;
4042

4143
Ok(ExecutionId(id))
4244
}
4345

4446
async fn load_execution(&self, id: ExecutionId) -> Result<Execution> {
45-
let mut conn = self.primary_pool.get_sync().await?;
46-
let execution = gce::table.find(id).first(&mut conn)?;
47+
let mut conn = self.primary_pool.get().await?;
48+
let execution = gce::table.find(id).first(&mut conn).await?;
4749

4850
Ok(execution)
4951
}
5052

5153
async fn mark_execution_as_running(&self, id: ExecutionId) -> Result<()> {
52-
let mut conn = self.primary_pool.get_sync().await?;
54+
let mut conn = self.primary_pool.get().await?;
5355

5456
diesel::update(gce::table)
5557
.set((
@@ -58,13 +60,14 @@ impl graphman_store::GraphmanStore for GraphmanStore {
5860
))
5961
.filter(gce::id.eq(id))
6062
.filter(gce::completed_at.is_null())
61-
.execute(&mut conn)?;
63+
.execute(&mut conn)
64+
.await?;
6265

6366
Ok(())
6467
}
6568

6669
async fn mark_execution_as_failed(&self, id: ExecutionId, error_message: String) -> Result<()> {
67-
let mut conn = self.primary_pool.get_sync().await?;
70+
let mut conn = self.primary_pool.get().await?;
6871

6972
diesel::update(gce::table)
7073
.set((
@@ -73,21 +76,23 @@ impl graphman_store::GraphmanStore for GraphmanStore {
7376
gce::completed_at.eq(Utc::now()),
7477
))
7578
.filter(gce::id.eq(id))
76-
.execute(&mut conn)?;
79+
.execute(&mut conn)
80+
.await?;
7781

7882
Ok(())
7983
}
8084

8185
async fn mark_execution_as_succeeded(&self, id: ExecutionId) -> Result<()> {
82-
let mut conn = self.primary_pool.get_sync().await?;
86+
let mut conn = self.primary_pool.get().await?;
8387

8488
diesel::update(gce::table)
8589
.set((
8690
gce::status.eq(ExecutionStatus::Succeeded),
8791
gce::completed_at.eq(Utc::now()),
8892
))
8993
.filter(gce::id.eq(id))
90-
.execute(&mut conn)?;
94+
.execute(&mut conn)
95+
.await?;
9196

9297
Ok(())
9398
}

store/postgres/src/primary.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1991,7 +1991,7 @@ impl Primary {
19911991
pub async fn is_source(&self, site: &Site) -> Result<bool, StoreError> {
19921992
use active_copies as ac;
19931993

1994-
let mut conn = self.pool.get_sync().await?;
1994+
let mut conn = self.pool.get().await?;
19951995

19961996
select(diesel::dsl::exists(
19971997
ac::table
@@ -2006,7 +2006,7 @@ impl Primary {
20062006
pub async fn is_copy_cancelled(&self, dst: &Site) -> Result<bool, StoreError> {
20072007
use active_copies as ac;
20082008

2009-
let mut conn = self.pool.get_sync().await?;
2009+
let mut conn = self.pool.get().await?;
20102010

20112011
ac::table
20122012
.filter(ac::dst.eq(dst.id))

store/postgres/src/relational/prune.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,7 +1010,7 @@ mod status {
10101010
pub async fn runs(&self) -> StoreResult<Vec<usize>> {
10111011
use prune_state as ps;
10121012

1013-
let mut conn = self.pool.get_sync().await?;
1013+
let mut conn = self.pool.get().await?;
10141014
let runs = ps::table
10151015
.filter(ps::id.eq(self.layout.site.id))
10161016
.select(ps::run)
@@ -1029,7 +1029,7 @@ mod status {
10291029
use prune_state as ps;
10301030
use prune_table_state as pts;
10311031

1032-
let mut conn = self.pool.get_sync().await?;
1032+
let mut conn = self.pool.get().await?;
10331033

10341034
let ptss = pts::table
10351035
.filter(pts::id.eq(self.layout.site.id))

store/test-store/src/store.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -410,15 +410,17 @@ pub async fn revert_block(store: &Arc<Store>, deployment: &DeploymentLocator, pt
410410

411411
pub async fn insert_ens_name(hash: &str, name: &str) {
412412
use diesel::insert_into;
413-
use diesel::prelude::*;
413+
use diesel::ExpressionMethods;
414+
use diesel_async::RunQueryDsl;
414415
use graph_store_postgres::command_support::catalog::ens_names;
415416

416-
let mut conn = PRIMARY_POOL.get_sync().await.unwrap();
417+
let mut conn = PRIMARY_POOL.get().await.unwrap();
417418

418419
insert_into(ens_names::table)
419420
.values((ens_names::hash.eq(hash), ens_names::name.eq(name)))
420421
.on_conflict_do_nothing()
421422
.execute(&mut conn)
423+
.await
422424
.unwrap();
423425
}
424426

0 commit comments

Comments
 (0)