#![warn(missing_docs)]
#![forbid(unsafe_code)]
mod delivery_state;
mod enqueue;
mod error;
mod finalize;
mod hydrate;
mod import;
mod lifecycle;
mod lifecycle_mutation;
mod migration;
mod page;
mod rls;
mod schema;
mod scope;
pub use error::{
ClaimError, EnqueueError, FinalizeError, ImportError, MutationError, PageError, SchemaError,
TransientKind,
};
#[allow(
deprecated,
reason = "Preserve the published 0.2.0 migration symbol and its bytes."
)]
pub use migration::V1_TENANT_ACTIVATE_SQL;
pub use migration::{
CrateVersion, LEGACY_MIGRATION, MIGRATIONS, Migration, MigrationCompatibility,
MigrationCompatibilityError, SCHEMA_VERSION, V1_TENANT_ACTIVATE_V2_SQL, V1_TENANT_PREPARE_SQL,
};
pub use page::SnapshotPager;
pub use rls::{RLS_PROFILE_SQL, bind_tenant};
pub use schema::check_schema;
use sqlx::PgPool;
pub use scope::{AdminDovecote, TenantDovecote};
#[derive(Clone)]
pub struct PostgresDovecote {
pool: PgPool,
}
impl PostgresDovecote {
#[must_use]
pub const fn new(pool: PgPool) -> Self {
Self { pool }
}
#[must_use]
pub const fn pool(&self) -> &PgPool {
&self.pool
}
#[must_use]
pub fn for_tenant(&self, tenant: dovecote::TenantId) -> TenantDovecote {
TenantDovecote::new(self.pool.clone(), tenant)
}
#[must_use]
pub fn admin(&self) -> AdminDovecote {
AdminDovecote::new(self.pool.clone())
}
pub async fn check_schema(&self) -> Result<(), SchemaError> {
check_schema(&self.pool).await
}
}