pub struct ModelDatabase { /* private fields */ }Expand description
SQLite-based model status tracker for distributed systems
Implementations§
Source§impl ModelDatabase
impl ModelDatabase
Sourcepub fn new(database_path: &str) -> Result<Self, Box<dyn Error>>
pub fn new(database_path: &str) -> Result<Self, Box<dyn Error>>
Create a new database instance and initialize the schema
Sourcepub fn get_status(&self, model_name: &str) -> SqliteResult<Option<ModelStatus>>
pub fn get_status(&self, model_name: &str) -> SqliteResult<Option<ModelStatus>>
Get the status of a model
Sourcepub fn get_model_record(
&self,
model_name: &str,
) -> SqliteResult<Option<ModelRecord>>
pub fn get_model_record( &self, model_name: &str, ) -> SqliteResult<Option<ModelRecord>>
Get the full record for a model
Sourcepub fn set_status(
&self,
model_name: &str,
provider: ModelProvider,
status: ModelStatus,
message: Option<String>,
) -> SqliteResult<()>
pub fn set_status( &self, model_name: &str, provider: ModelProvider, status: ModelStatus, message: Option<String>, ) -> SqliteResult<()>
Set the status of a model, creating or updating the record
Sourcepub fn touch_model(&self, model_name: &str) -> SqliteResult<()>
pub fn touch_model(&self, model_name: &str) -> SqliteResult<()>
Update the last_used_at timestamp for a model
Sourcepub fn delete_model(&self, model_name: &str) -> SqliteResult<()>
pub fn delete_model(&self, model_name: &str) -> SqliteResult<()>
Delete a model record
Sourcepub fn get_models_by_last_used(
&self,
limit: Option<u32>,
) -> SqliteResult<Vec<ModelRecord>>
pub fn get_models_by_last_used( &self, limit: Option<u32>, ) -> SqliteResult<Vec<ModelRecord>>
Get models ordered by last used (oldest first) - for future LRU cleanup
Sourcepub fn get_status_counts(&self) -> SqliteResult<(u32, u32, u32)>
pub fn get_status_counts(&self) -> SqliteResult<(u32, u32, u32)>
Get count of models with each status - for monitoring
Sourcepub fn try_claim_for_download(
&self,
model_name: &str,
provider: ModelProvider,
) -> SqliteResult<ModelStatus>
pub fn try_claim_for_download( &self, model_name: &str, provider: ModelProvider, ) -> SqliteResult<ModelStatus>
Atomically attempt to claim a model for downloading using compare-and-swap semantics Returns the current status of the model:
- If model doesn’t exist, creates it with DOWNLOADING status and returns DOWNLOADING
- If model exists, returns its current status without modification This prevents race conditions in distributed environments
Trait Implementations§
Source§impl Clone for ModelDatabase
impl Clone for ModelDatabase
Source§fn clone(&self) -> ModelDatabase
fn clone(&self) -> ModelDatabase
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for ModelDatabase
impl RefUnwindSafe for ModelDatabase
impl Send for ModelDatabase
impl Sync for ModelDatabase
impl Unpin for ModelDatabase
impl UnwindSafe for ModelDatabase
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
Mutably borrows from an owned value. Read more
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request