pub struct MigrationController { /* private fields */ }Expand description
Manages the state machine for a single migration.
§Example
use lattice_embed::migration::{MigrationController, MigrationPlan};
use lattice_embed::EmbeddingModel;
let plan = MigrationPlan {
id: "mig-001".to_string(),
source_model: EmbeddingModel::BgeSmallEnV15,
target_model: EmbeddingModel::BgeBaseEnV15,
total_embeddings: 100,
batch_size: 50,
created_at: "2026-01-27T00:00:00Z".to_string(),
};
let mut ctrl = MigrationController::new(plan);
ctrl.start().unwrap();
ctrl.record_progress(50).unwrap();
let report = ctrl.progress();
assert!(report.state.is_active());
assert_eq!(report.state.processed(), 50);Implementations§
Source§impl MigrationController
impl MigrationController
Sourcepub fn new(plan: MigrationPlan) -> Self
pub fn new(plan: MigrationPlan) -> Self
Create a new migration controller from a plan.
Sourcepub fn start(&mut self) -> Result<(), MigrationError>
pub fn start(&mut self) -> Result<(), MigrationError>
Start the migration (Planned -> InProgress).
Sourcepub fn record_progress(
&mut self,
newly_processed: usize,
) -> Result<(), MigrationError>
pub fn record_progress( &mut self, newly_processed: usize, ) -> Result<(), MigrationError>
Record that newly_processed embeddings were completed.
Sourcepub fn record_error(&mut self)
pub fn record_error(&mut self)
Record a non-fatal error during processing.
Sourcepub fn record_skip(&mut self, reason: SkipReason) -> Result<(), MigrationError>
pub fn record_skip(&mut self, reason: SkipReason) -> Result<(), MigrationError>
Record an item that will be permanently skipped.
§Example
use lattice_embed::migration::{MigrationController, MigrationPlan, SkipReason};
use lattice_embed::EmbeddingModel;
let plan = MigrationPlan {
id: "mig-001".to_string(),
source_model: EmbeddingModel::BgeSmallEnV15,
target_model: EmbeddingModel::BgeBaseEnV15,
total_embeddings: 100,
batch_size: 50,
created_at: "2026-01-27T00:00:00Z".to_string(),
};
let mut ctrl = MigrationController::new(plan);
ctrl.start().unwrap();
ctrl.record_skip(SkipReason::ContentTooLarge { size: 50000, max: 8192 }).unwrap();
assert_eq!(ctrl.state().skipped(), 1);Sourcepub fn skip_reasons(&self) -> &[SkipReason]
pub fn skip_reasons(&self) -> &[SkipReason]
Returns the list of reasons why entries were skipped during migration.
Sourcepub fn effective_coverage(&self) -> f64
pub fn effective_coverage(&self) -> f64
Returns the effective coverage fraction (0.0–1.0) of the migration.
Sourcepub fn pause(&mut self, reason: impl Into<String>) -> Result<(), MigrationError>
pub fn pause(&mut self, reason: impl Into<String>) -> Result<(), MigrationError>
Pause the migration (InProgress -> Paused).
Sourcepub fn resume(&mut self) -> Result<(), MigrationError>
pub fn resume(&mut self) -> Result<(), MigrationError>
Resume the migration (Paused/Failed -> InProgress).
Sourcepub fn fail(&mut self, error: impl Into<String>) -> Result<(), MigrationError>
pub fn fail(&mut self, error: impl Into<String>) -> Result<(), MigrationError>
Fail the migration (InProgress -> Failed).
Sourcepub fn cancel(&mut self) -> Result<(), MigrationError>
pub fn cancel(&mut self) -> Result<(), MigrationError>
Cancel the migration (any non-terminal state -> Cancelled).
Sourcepub fn progress(&self) -> MigrationProgress
pub fn progress(&self) -> MigrationProgress
Get a snapshot of current progress.
Sourcepub fn state(&self) -> &MigrationState
pub fn state(&self) -> &MigrationState
Returns the current migration state.
Sourcepub fn plan(&self) -> &MigrationPlan
pub fn plan(&self) -> &MigrationPlan
Returns the migration plan.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for MigrationController
impl RefUnwindSafe for MigrationController
impl Send for MigrationController
impl Sync for MigrationController
impl Unpin for MigrationController
impl UnsafeUnpin for MigrationController
impl UnwindSafe for MigrationController
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