Expand description
Enhanced index lifecycle state machine for production readiness.
This module provides a comprehensive state machine for index lifecycle management with additional states for initialization, updating, invalidation, and error handling. The state machine ensures thread-safe state transitions with proper guards and error recovery mechanisms.
§State Machine States
- Idle: Index is idle and not initialized
- Initializing: Index is being initialized
- Building: Index is being built (workspace scan in progress)
- Updating: Index is being updated (incremental changes)
- Invalidating: Index is being invalidated
- Ready: Index is ready for queries
- Degraded: Index is degraded but partially functional
- Error: Index is in error state
§State Transitions
Idle → Initializing → Building → Updating → Ready
↓ ↓ ↓ ↓ ↓
Error ← Error ← Error ← Error ← Error ← Error
↓ ↓ ↓ ↓ ↓
Degraded ← Degraded ← Degraded ← Degraded ← Degraded§Thread Safety
- All state transitions are protected by RwLock
- State reads are lock-free (cloned state)
- State writes use exclusive locks
- Guards prevent invalid transitions
§Usage
ⓘ
use perl_workspace_index_state_machine::{IndexStateMachine, IndexState};
let machine = IndexStateMachine::new();
assert!(matches!(machine.state(), IndexState::Idle));
machine.transition_to_initializing();
machine.transition_to_building(100); // 100 files to indexStructs§
- Build
Phase Transition - A phase transition while building the workspace index.
- Index
State Machine - Thread-safe index state machine.
- Index
State Transition - State transition for index lifecycle instrumentation.
Enums§
- Build
Phase - Build phases for the Building state.
- Degradation
Reason - Reason for index degradation.
- Index
State - Enhanced index state with additional production-ready states.
- Index
State Kind - Coarse index state kinds for instrumentation and transition tracking.
- Invalidation
Reason - Reason for index invalidation.
- Resource
Kind - Type of resource limit that was exceeded.
- Transition
Result - Result of a state transition attempt.