pub struct Database { /* private fields */ }Expand description
Thin wrapper around a SQLite connection pool.
Implementations§
Source§impl Database
impl Database
Sourcepub async fn open(db_path: &Path) -> Result<Self, DbError>
pub async fn open(db_path: &Path) -> Result<Self, DbError>
Opens the SQLite database and runs embedded migrations.
Uses up to DB_POOL_MAX_CONNECTIONS pooled connections so UI reads can
stay responsive without oversizing the SQLite pool beyond what WAL
can use effectively. Applies a short busy timeout so bursty reducer
writes wait briefly for the single SQLite writer instead of failing
immediately with SQLITE_BUSY.
§Errors
Returns an error if the directory cannot be created, the database cannot be opened, or migrations fail.
Sourcepub async fn open_with_timestamp_source(
db_path: &Path,
timestamp_source: Arc<dyn TimestampSource>,
) -> Result<Self, DbError>
pub async fn open_with_timestamp_source( db_path: &Path, timestamp_source: Arc<dyn TimestampSource>, ) -> Result<Self, DbError>
Opens the SQLite database with an injected persistence timestamp
source.
§Errors
Returns an error if the directory cannot be created, the database cannot be opened, or migrations fail.
Sourcepub async fn open_in_memory() -> Result<Self, DbError>
pub async fn open_in_memory() -> Result<Self, DbError>
Opens an in-memory SQLite database and runs migrations.
This is primarily used by tests and any ephemeral workflows that need an isolated database instance while keeping the same durability and foreign-key settings as the on-disk database. Applies the same short busy timeout as the on-disk configuration so tests exercise the same writer wait policy.
§Errors
Returns an error if the database connection or migrations fail.
Sourcepub async fn open_in_memory_with_timestamp_source(
timestamp_source: Arc<dyn TimestampSource>,
) -> Result<Self, DbError>
pub async fn open_in_memory_with_timestamp_source( timestamp_source: Arc<dyn TimestampSource>, ) -> Result<Self, DbError>
Opens an in-memory SQLite database with an injected timestamp source.
§Errors
Returns an error if the database connection or migrations fail.
Sourcepub fn pool(&self) -> &SqlitePool
pub fn pool(&self) -> &SqlitePool
Returns the shared SQLite connection pool for lower-level query
access.
Methods from Deref<Target = AppRepositories>§
Sourcepub fn activity(&self) -> &dyn ActivityRepository
pub fn activity(&self) -> &dyn ActivityRepository
Returns the activity-event repository.
Sourcepub fn operations(&self) -> &dyn OperationRepository
pub fn operations(&self) -> &dyn OperationRepository
Returns the session-operation repository.
Sourcepub fn orchestrations(&self) -> &dyn OrchestrationRepository
pub fn orchestrations(&self) -> &dyn OrchestrationRepository
Returns the orchestration repository.
Sourcepub fn orchestration_repository(&self) -> Arc<dyn OrchestrationRepository> ⓘ
pub fn orchestration_repository(&self) -> Arc<dyn OrchestrationRepository> ⓘ
Returns a cloneable orchestration repository for background reconciliation.
Sourcepub fn projects(&self) -> &dyn ProjectRepository
pub fn projects(&self) -> &dyn ProjectRepository
Returns the project repository.
Sourcepub fn reviews(&self) -> &dyn ReviewRepository
pub fn reviews(&self) -> &dyn ReviewRepository
Returns the session review-request repository.
Sourcepub fn sessions(&self) -> &dyn SessionRepository
pub fn sessions(&self) -> &dyn SessionRepository
Returns the session repository.
Sourcepub fn settings(&self) -> &dyn SettingRepository
pub fn settings(&self) -> &dyn SettingRepository
Returns the settings repository.
Sourcepub fn usage(&self) -> &dyn UsageRepository
pub fn usage(&self) -> &dyn UsageRepository
Returns the per-session usage repository.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Database
impl !UnwindSafe for Database
impl Freeze for Database
impl Send for Database
impl Sync for Database
impl Unpin for Database
impl UnsafeUnpin for Database
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more