pub struct Db { /* private fields */ }Expand description
Async wrapper around a single SQLite connection.
Holds an optional notifier so that every task insert performed via
storage::tasks::insert reaches the scheduler — not just inserts from
the MCP tool layer. Without this, tasks inserted from background workers
or fetcher paths would sit running forever in the inserting process,
since the orphan scanner deliberately excludes live servers.pid rows.
Implementations§
Source§impl Db
impl Db
Sourcepub async fn upsert_server_self(
&self,
pid: i64,
version: String,
) -> Result<(), StorageError>
pub async fn upsert_server_self( &self, pid: i64, version: String, ) -> Result<(), StorageError>
Upsert the current process’s row. If a row already exists for pid
(from a crashed prior run of this PID), its started_at is reset.
Sourcepub async fn heartbeat_server(&self, pid: i64) -> Result<(), StorageError>
pub async fn heartbeat_server(&self, pid: i64) -> Result<(), StorageError>
Refresh last_heartbeat for pid. If no row exists, this is a no-op
(logged at the caller).
Sourcepub async fn reap_stale_servers(
&self,
threshold: Duration,
) -> Result<usize, StorageError>
pub async fn reap_stale_servers( &self, threshold: Duration, ) -> Result<usize, StorageError>
Delete rows whose last_heartbeat is older than threshold ago.
Returns the number of rows removed.
Sourcepub async fn delete_server_self(&self, pid: i64) -> Result<(), StorageError>
pub async fn delete_server_self(&self, pid: i64) -> Result<(), StorageError>
Remove the row for pid (idempotent).
Sourcepub async fn list_servers(&self) -> Result<Vec<ServerRow>, StorageError>
pub async fn list_servers(&self) -> Result<Vec<ServerRow>, StorageError>
Read all rows. Used by tests and by future M3 integration scenarios.
Source§impl Db
impl Db
Sourcepub fn set_new_task_sender(&self, tx: NewTaskNotify)
pub fn set_new_task_sender(&self, tx: NewTaskNotify)
Install the scheduler-bound new-task notifier. Called once, after the
scheduler channel exists, by mcp::server::serve_stdio.
Sourcepub fn path(&self) -> &Path
pub fn path(&self) -> &Path
Path the underlying SQLite file was opened from.
Used by register_tasks_update_hook to open a dedicated sibling
connection on which the update_hook is installed.
Source§impl Db
impl Db
Sourcepub async fn open(path: impl AsRef<Path>) -> Result<Self, StorageError>
pub async fn open(path: impl AsRef<Path>) -> Result<Self, StorageError>
Open the database at path, applying any pending migrations.
Sourcepub async fn schema_version(&self) -> Result<u32, StorageError>
pub async fn schema_version(&self) -> Result<u32, StorageError>
Current schema version (for rover doctor and tests).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Db
impl RefUnwindSafe for Db
impl Send for Db
impl Sync for Db
impl Unpin for Db
impl UnsafeUnpin for Db
impl UnwindSafe for Db
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