-
Notifications
You must be signed in to change notification settings - Fork 13
Refactor V3MutationService and V3CompatibleTableBinding to eliminate duplicate code #195
Copy link
Copy link
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
Background
V3MutationService.kt and V3CompatibleTableBinding.kt contain 95%+ identical code between mutateEdge and mutateMultiEdge methods. This duplication has already caused a bug: mutateMultiEdge is missing LockAcquisitionFailedException error handling that mutateEdge has — errors propagate and fail the entire request instead of returning ERROR status and clearing stale locks.
Task
- V3CompatibleTableBinding: Extract
buildHBaseMutations()private helper (100% identical HBase mutation construction: Put, Increment, Delete) - V3CompatibleTableBinding: Extract
decodeCurrentState()private helper (identical state decoding logic) - V3MutationService: Extract
resolveMutationContext()helper (label validation + context initialization) - V3MutationService: Extract
writeCdc()helper (CDC message creation + publish) - V3MutationService: Extract
handleMutationError()helper and apply to both methods - Bug fix: Add
onErrorResumeforLockAcquisitionFailedExceptiontomutateMultiEdge
Done When
- All existing tests pass (
./gradlew :engine:test,./gradlew :server:test) - No changes to public API signatures (controller compatibility preserved)
- No changes to core module types
mutateMultiEdgehandlesLockAcquisitionFailedExceptionidentically tomutateEdge
Notes
- Minimal extraction approach — small helper functions, no heavyweight generics or sealed interfaces
- Expected reduction: V3CompatibleTableBinding ~65 lines, V3MutationService ~50 lines
- Key difference between Edge/MultiEdge:
Pair<Any, Any>(source, target) vs singleAny(id) key
Created by claude code (opus 4.6)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request