Skip to content

Commit

Permalink
feat: convenient wrapper for Postgres advisory locks
Browse files Browse the repository at this point in the history
  • Loading branch information
abonander committed Mar 24, 2022
1 parent f539215 commit cb78292
Show file tree
Hide file tree
Showing 8 changed files with 527 additions and 9 deletions.
15 changes: 13 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions sqlx-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ postgres = [
"json",
"dirs",
"whoami",
"hkdf"
]
mysql = [
"sha-1",
Expand Down Expand Up @@ -168,6 +169,7 @@ hashlink = "0.7.0"
# NOTE: *must* remain below 1.7.0 to allow users to avoid the `ahash` cyclic dependency problem by pinning the version
# https://github.com/tkaitchuck/aHash/issues/95#issuecomment-874150078
indexmap = "1.6.0"
hkdf = { version = "0.11.0", optional = true }

[dev-dependencies]
sqlx = { version = "0.5.11", path = "..", features = ["postgres", "sqlite"] }
12 changes: 12 additions & 0 deletions sqlx-core/src/pool/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,18 @@ impl<DB: Database> DerefMut for PoolConnection<DB> {
}
}

impl<DB: Database> AsRef<DB::Connection> for PoolConnection<DB> {
fn as_ref(&self) -> &DB::Connection {
self
}
}

impl<DB: Database> AsMut<DB::Connection> for PoolConnection<DB> {
fn as_mut(&mut self) -> &mut DB::Connection {
self
}
}

impl<DB: Database> PoolConnection<DB> {
/// Explicitly release a connection from the pool
#[deprecated = "renamed to `.detach()` for clarity"]
Expand Down
Loading

0 comments on commit cb78292

Please sign in to comment.