mirror of
https://github.com/block/buzz.git
synced 2026-11-07 18:01:06 +00:00
refactor(db): move deletion store ownership
Signed-off-by: OpenAI Codex <codex@openai.com>
This commit is contained in:
committed by
Luke Tornquist
parent
e4405174f7
commit
3ac5ac7306
@@ -17,6 +17,7 @@ use sqlx::{AssertSqlSafe, PgConnection, PgPool, Postgres, Row, Transaction};
|
||||
use uuid::Uuid;
|
||||
|
||||
use crate::error::{DbError, Result};
|
||||
use crate::Db;
|
||||
|
||||
/// Default PostgreSQL lease duration for one claimed deletion request.
|
||||
pub const DEFAULT_LEASE_DURATION: Duration = Duration::from_secs(60);
|
||||
@@ -627,6 +628,23 @@ pub struct DeletionStore {
|
||||
pool: PgPool,
|
||||
}
|
||||
|
||||
impl Db {
|
||||
/// Validate the minimum deletion fence catalog required by serving paths.
|
||||
pub async fn validate_deletion_serving_catalog(&self) -> Result<()> {
|
||||
self.deletion_store().validate_serving_catalog().await
|
||||
}
|
||||
|
||||
/// Validate the exact live community-deletion tenant catalog for destruction.
|
||||
pub async fn validate_deletion_catalog(&self) -> Result<()> {
|
||||
self.deletion_store().validate_catalog().await
|
||||
}
|
||||
|
||||
/// Return the shared durable whole-community deletion adapter.
|
||||
pub fn deletion_store(&self) -> DeletionStore {
|
||||
DeletionStore::new(self.pool.clone())
|
||||
}
|
||||
}
|
||||
|
||||
impl DeletionStore {
|
||||
/// Construct from the writer pool used by [`crate::Db`].
|
||||
pub(crate) fn new(pool: PgPool) -> Self {
|
||||
|
||||
@@ -954,16 +954,6 @@ impl Db {
|
||||
sqlx::query("SELECT 1").execute(&self.pool).await.is_ok()
|
||||
}
|
||||
|
||||
/// Validate the minimum deletion fence catalog required by serving paths.
|
||||
pub async fn validate_deletion_serving_catalog(&self) -> Result<()> {
|
||||
self.deletion_store().validate_serving_catalog().await
|
||||
}
|
||||
|
||||
/// Validate the exact live community-deletion tenant catalog for destruction.
|
||||
pub async fn validate_deletion_catalog(&self) -> Result<()> {
|
||||
self.deletion_store().validate_catalog().await
|
||||
}
|
||||
|
||||
/// Returns pool utilisation stats for metrics emission.
|
||||
///
|
||||
/// `size` — total connections (idle + active)
|
||||
@@ -993,11 +983,6 @@ impl Db {
|
||||
})
|
||||
}
|
||||
|
||||
/// Return the shared durable whole-community deletion adapter.
|
||||
pub fn deletion_store(&self) -> deletion::DeletionStore {
|
||||
deletion::DeletionStore::new(self.pool.clone())
|
||||
}
|
||||
|
||||
/// Begin a database transaction for atomic multi-statement operations.
|
||||
///
|
||||
/// Returns a `'static` transaction because `PgPool` is `Arc`-backed internally.
|
||||
|
||||
Reference in New Issue
Block a user