Skip to content

Commit ab63011

Browse files
committed
store: Remove PermittedConnection.into_inner
1 parent 77d2043 commit ab63011

File tree

3 files changed

+9
-17
lines changed

3 files changed

+9
-17
lines changed

store/postgres/src/pool/mod.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,6 @@ pub struct PermittedConnection {
5151
_permit: tokio::sync::OwnedSemaphorePermit,
5252
}
5353

54-
impl PermittedConnection {
55-
/// Returns the underlying connection, consuming the permit.
56-
/// The permit is released when this method is called.
57-
pub fn into_inner(self) -> AsyncPgConnection {
58-
self.conn
59-
}
60-
}
61-
6254
impl Deref for PermittedConnection {
6355
type Target = AsyncPgConnection;
6456
fn deref(&self) -> &Self::Target {

store/postgres/src/primary.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
use crate::{
55
block_range::UNVERSIONED_RANGE,
66
detail::DeploymentDetail,
7-
pool::PRIMARY_PUBLIC,
7+
pool::{PermittedConnection, PRIMARY_PUBLIC},
88
subgraph_store::{unused, Shard, PRIMARY_SHARD},
99
AsyncPgConnection, ConnectionPool, ForeignServer, NotificationSender,
1010
};
@@ -779,11 +779,11 @@ mod queries {
779779
/// A wrapper for a database connection that provides access to functionality
780780
/// that works only on the primary database
781781
pub struct Connection {
782-
conn: AsyncPgConnection,
782+
conn: PermittedConnection,
783783
}
784784

785785
impl Connection {
786-
pub fn new(conn: AsyncPgConnection) -> Self {
786+
pub fn new(conn: PermittedConnection) -> Self {
787787
Self { conn }
788788
}
789789

@@ -807,13 +807,13 @@ impl Connection {
807807
type TM = <AsyncPgConnection as diesel_async::AsyncConnection>::TransactionManager;
808808

809809
async move {
810-
TM::begin_transaction(&mut self.conn).await?;
810+
TM::begin_transaction(&mut *self.conn).await?;
811811
match callback(self).await {
812812
Ok(value) => {
813-
TM::commit_transaction(&mut self.conn).await?;
813+
TM::commit_transaction(&mut *self.conn).await?;
814814
Ok(value)
815815
}
816-
Err(user_error) => match TM::rollback_transaction(&mut self.conn).await {
816+
Err(user_error) => match TM::rollback_transaction(&mut *self.conn).await {
817817
Ok(()) => Err(user_error),
818818
Err(diesel::result::Error::BrokenTransactionManager) => {
819819
// In this case we are probably more interested by the

store/postgres/src/subgraph_store.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -819,7 +819,7 @@ impl Inner {
819819
/// of connections in between getting the first one and trying to get the
820820
/// second one.
821821
pub(crate) async fn primary_conn(&self) -> Result<primary::Connection, StoreError> {
822-
let conn = self.mirror.primary().get().await?;
822+
let conn = self.mirror.primary().get_permitted().await?;
823823
Ok(primary::Connection::new(conn))
824824
}
825825

@@ -1381,15 +1381,15 @@ impl EnsLookup {
13811381
}
13821382

13831383
async fn is_table_empty(pool: &ConnectionPool) -> Result<bool, StoreError> {
1384-
let conn = pool.get_permitted().await?.into_inner();
1384+
let conn = pool.get_permitted().await?;
13851385
primary::Connection::new(conn).is_ens_table_empty().await
13861386
}
13871387
}
13881388

13891389
#[async_trait]
13901390
impl EnsLookupTrait for EnsLookup {
13911391
async fn find_name(&self, hash: &str) -> Result<Option<String>, StoreError> {
1392-
let conn = self.primary.get_permitted().await?.into_inner();
1392+
let conn = self.primary.get_permitted().await?;
13931393
primary::Connection::new(conn).find_ens_name(hash).await
13941394
}
13951395

0 commit comments

Comments
 (0)