pub struct ModelRegistry { /* private fields */ }Expand description
Thread-safe registry with optional durable backend.
Cloning is cheap — the Arcs shared. Mutations flush to the
attached MlPersistence (when present) so state survives
restart. Without a backend the registry is pure in-memory, which
is what the unit tests use.
Implementations§
Source§impl ModelRegistry
impl ModelRegistry
pub fn new() -> ModelRegistry
Sourcepub fn with_backend(backend: Arc<dyn MlPersistence>) -> ModelRegistry
pub fn with_backend(backend: Arc<dyn MlPersistence>) -> ModelRegistry
Build a registry that persists mutations to backend and
rehydrates from any existing entries. Callers typically
construct this once at startup via the runtime helper.
Sourcepub fn load_from_backend(&self) -> Result<(), ModelRegistryError>
pub fn load_from_backend(&self) -> Result<(), ModelRegistryError>
Read every persisted model + version back into memory. Called
implicitly by Self::with_backend; also exposed so tests
can assert round-trip.
Sourcepub fn register_version(
&self,
model: impl Into<String>,
version: ModelVersion,
make_active: bool,
) -> Result<u32, ModelRegistryError>
pub fn register_version( &self, model: impl Into<String>, version: ModelVersion, make_active: bool, ) -> Result<u32, ModelRegistryError>
Register a new version of model. Returns the new version
number, which is always max(existing) + 1.
The registered version becomes the active one automatically
unless make_active = false — callers who want to validate
before publishing pass false and later call
Self::set_active_version.
Sourcepub fn set_active_version(
&self,
model: &str,
version: u32,
) -> Result<(), ModelRegistryError>
pub fn set_active_version( &self, model: &str, version: u32, ) -> Result<(), ModelRegistryError>
Point the active_version at version. Errors if the version
does not exist or is archived.
Sourcepub fn archive_version(
&self,
model: &str,
version: u32,
) -> Result<(), ModelRegistryError>
pub fn archive_version( &self, model: &str, version: u32, ) -> Result<(), ModelRegistryError>
Flag a version as archived. Archived versions remain readable
(so offline audits work) but cannot be made active. If the
archived version was the active one, active_version is
cleared — operator must explicitly pick a new active version.
Sourcepub fn get_version(
&self,
model: &str,
version: u32,
) -> Result<ModelVersion, ModelRegistryError>
pub fn get_version( &self, model: &str, version: u32, ) -> Result<ModelVersion, ModelRegistryError>
Fetch a specific version. Clones because callers typically need an owned blob.
Sourcepub fn get_active(
&self,
model: &str,
) -> Result<Option<ModelVersion>, ModelRegistryError>
pub fn get_active( &self, model: &str, ) -> Result<Option<ModelVersion>, ModelRegistryError>
Fetch the currently-active version of model, if one is set.
Sourcepub fn list_versions(
&self,
model: &str,
) -> Result<Vec<ModelVersion>, ModelRegistryError>
pub fn list_versions( &self, model: &str, ) -> Result<Vec<ModelVersion>, ModelRegistryError>
List every version of model, oldest first.
Sourcepub fn summaries(&self) -> Result<Vec<ModelSummary>, ModelRegistryError>
pub fn summaries(&self) -> Result<Vec<ModelSummary>, ModelRegistryError>
One-line summary per model.
Trait Implementations§
Source§impl Clone for ModelRegistry
impl Clone for ModelRegistry
Source§fn clone(&self) -> ModelRegistry
fn clone(&self) -> ModelRegistry
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ModelRegistry
impl Debug for ModelRegistry
Source§impl Default for ModelRegistry
impl Default for ModelRegistry
Source§fn default() -> ModelRegistry
fn default() -> ModelRegistry
Auto Trait Implementations§
impl Freeze for ModelRegistry
impl !RefUnwindSafe for ModelRegistry
impl Send for ModelRegistry
impl Sync for ModelRegistry
impl Unpin for ModelRegistry
impl UnsafeUnpin for ModelRegistry
impl !UnwindSafe for ModelRegistry
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 moreSource§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>
T in a tonic::Request