-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Summary
The service layer directly imports and uses version-specific state machine implementation (SMV003), creating tight coupling between layers.
Location
crates/service/src/store/meta_raft_state_machine/mod.rs:27-29
use databend_meta_raft_store::sm_v003::SMV003;
use databend_meta_raft_store::sm_v003::SnapshotStoreV004;
use databend_meta_raft_store::sm_v003::WriteEntry;Problem
The service layer is tightly coupled to a specific storage version (sm_v003). This makes it difficult to:
- Swap out storage implementations for testing
- Upgrade to new storage versions without changing service code
- Test service logic independently of storage
Impact
- Upgrading storage versions requires changes across multiple crates
- Unit testing service logic requires the full storage stack
- Abstraction boundaries are violated
Suggested Fix
Create a trait abstraction in raft-store that hides version-specific details:
// In raft-store
pub trait StateMachineStorage: Send + Sync {
async fn apply(&self, entry: WriteEntry) -> Result<()>;
async fn snapshot(&self) -> Result<Snapshot>;
// ... other operations
}
// SMV003 implements this trait
impl StateMachineStorage for SMV003 { ... }
// Service uses the trait, not the concrete type
pub struct MetaRaftStateMachine<S: StateMachineStorage> {
storage: S,
}Priority
P2 - Architecture improvement
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request