refactor: Batch 4 step 1 — typed PendingExecution, zero type assertions

Replace interface{} fields in runtime.PendingExecution with typed handles:
- Driver: *engine.RecoveryDriver (was interface{})
- Plan: *engine.RecoveryPlan (was interface{})
- CatchUpIO: engine.CatchUpIO (was interface{})
- RebuildIO: engine.RebuildIO (was interface{})

block_recovery.go:
- ExecutePendingCatchUp/Rebuild: direct field access (pe.Driver, pe.Plan)
  instead of type assertions (pe.Driver.(*engine.RecoveryDriver))
- CancelFunc: pe.Driver.CancelPlan(pe.Plan, reason) — no casts
- 6 type assertions removed from production path

Test files: remove Plan type assertions — fields are typed end-to-end.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
pingqiuandClaude Opus 4.6 committed 2026-04-04 01:27:29 -07:00
1 parent 3a5fbbfded
commit 0bcfc678d0
4 files changed
+24 -39

No files matched your search

+16 -9
View File
@@ -3,29 +3,36 @@
// be used by any adapter shell.
package runtime
import "sync"
import (
"sync"
engine "github.com/seaweedfs/seaweedfs/sw-block/engine/replication"
)
// PendingExecution holds the state needed to execute a planned recovery
// action. The coordinator stores one pending execution per volume and
// matches it against incoming commands.
//
// All fields are typed — no interface{} handles. The host adapter builds
// these from concrete BlockVol bindings; the coordinator and execution
// helpers consume them without type assertions.
type PendingExecution struct {
VolumeID string
ReplicaID string
// CatchUpTarget is the target LSN for catch-up execution.
// Used by ExecutePendingCatchUp for fail-closed target matching.
// Used by TakeCatchUp for fail-closed target matching.
CatchUpTarget uint64
// RebuildTargetLSN is the target LSN for rebuild execution.
// Used by ExecutePendingRebuild for fail-closed target matching.
// Used by TakeRebuild for fail-closed target matching.
RebuildTargetLSN uint64
// Opaque handles — the coordinator stores these but doesn't interpret them.
// The host adapter supplies concrete types (driver, plan, IO bindings).
Driver interface{}
Plan interface{}
CatchUpIO interface{}
RebuildIO interface{}
// Typed recovery handles — no interface{} drift.
Driver *engine.RecoveryDriver
Plan *engine.RecoveryPlan
CatchUpIO engine.CatchUpIO
RebuildIO engine.RebuildIO
}
// CancelFunc is called when a pending execution is cancelled due to