dovecote_sqlx_postgres/
lib.rs1#![warn(missing_docs)]
10
11mod delivery_state;
12mod enqueue;
13mod error;
14mod finalize;
15mod hydrate;
16mod import;
17mod lifecycle;
18mod lifecycle_mutation;
19mod migration;
20mod page;
21mod rls;
22mod schema;
23mod scope;
24
25pub use error::{
26 ClaimError, EnqueueError, FinalizeError, ImportError, MutationError, PageError, SchemaError,
27 TransientKind,
28};
29#[allow(deprecated)]
30pub use migration::{
31 CrateVersion, LEGACY_MIGRATION, MIGRATIONS, Migration, MigrationCompatibility,
32 MigrationCompatibilityError, SCHEMA_VERSION, V1_TENANT_ACTIVATE_SQL, V1_TENANT_ACTIVATE_V2_SQL,
33 V1_TENANT_PREPARE_SQL,
34};
35pub use page::SnapshotPager;
36pub use rls::{RLS_PROFILE_SQL, bind_tenant};
37pub use schema::check_schema;
38
39use sqlx::PgPool;
40
41pub use scope::{AdminDovecote, TenantDovecote};
42
43#[derive(Clone)]
45pub struct PostgresDovecote {
46 pool: PgPool,
47}
48
49impl PostgresDovecote {
50 pub fn new(pool: PgPool) -> Self {
52 Self { pool }
53 }
54
55 pub fn pool(&self) -> &PgPool {
57 &self.pool
58 }
59
60 pub fn for_tenant(&self, tenant: dovecote::TenantId) -> TenantDovecote {
62 TenantDovecote::new(self.pool.clone(), tenant)
63 }
64
65 pub fn admin(&self) -> AdminDovecote {
70 AdminDovecote::new(self.pool.clone())
71 }
72
73 pub async fn check_schema(&self) -> Result<(), SchemaError> {
76 check_schema(&self.pool).await
77 }
78}