package v2bridge import ( "fmt" "github.com/seaweedfs/seaweedfs/weed/storage/blockvol" ) // Executor performs real recovery I/O using blockvol internals. // It executes what the engine tells it to do — it does NOT decide // recovery policy. // // Phase 07 P1: one narrow path (WAL catch-up streaming). // Full-base rebuild and snapshot transfer are deferred. type Executor struct { vol *blockvol.BlockVol } // NewExecutor creates an executor for a real blockvol instance. func NewExecutor(vol *blockvol.BlockVol) *Executor { return &Executor{vol: vol} } // StreamWALEntries reads WAL entries from startExclusive+1 to endInclusive // using BlockVol.ScanWALEntries (real ScanFrom mechanism). // Returns the highest LSN successfully scanned. // // This is the real catch-up data path. The callback receives each entry // for shipping to the replica (network-layer apply is the caller's job). func (e *Executor) StreamWALEntries(startExclusive, endInclusive uint64) (uint64, error) { if e.vol == nil { return 0, fmt.Errorf("no blockvol instance") } var highestLSN uint64 err := e.vol.ScanWALEntries(startExclusive+1, func(entry *blockvol.WALEntry) error { if entry.LSN > endInclusive { return nil // past requested range, stop } // In production: ship entry to replica over network. // Here: track the highest LSN successfully read. highestLSN = entry.LSN return nil }) if err != nil { return highestLSN, fmt.Errorf("WAL scan from %d: %w", startExclusive, err) } return highestLSN, nil } // TransferSnapshot transfers a checkpoint/snapshot. Stub for P1. func (e *Executor) TransferSnapshot(snapshotLSN uint64) error { return fmt.Errorf("TransferSnapshot not implemented in P1") } // TransferFullBase transfers the full extent image. Stub for P1. func (e *Executor) TransferFullBase(committedLSN uint64) error { return fmt.Errorf("TransferFullBase not implemented in P1") } // TruncateWAL removes entries beyond truncateLSN. Stub for P1. func (e *Executor) TruncateWAL(truncateLSN uint64) error { return fmt.Errorf("TruncateWAL not implemented in P1") }