mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-08-22 07:06:51 +00:00
V2 runtime packages: - sw-block/runtime/masterv2: identity authority (desired state, heartbeat handling, promotion arbitration via SelectPromotionCandidate) - sw-block/runtime/volumev2: per-volume micro-cluster shell (node, orchestrator, control session, iSCSI frontend, takeover gate, failover session + driver, replica summary reconstruction) - sw-block/runtime/purev2: RF1 execution shell (engine + store + dispatcher + local boundary observations) - sw-block/runtime/protocolv2: three-channel separation (heartbeat/assignment/query + replica summary) V2 binaries: - sw-block/cmd/v2singleblock: single-node RF1 block server - sw-block/cmd/purev2rf1: minimal RF1 runtime binary Milestone capabilities: - RF1 write/read/sync with engine-driven mode projection - masterv2 ↔ volumev2 heartbeat convergence + assignment reissue - Promotion query with fresh CommittedLSN/WALHeadLSN evidence - Replica summary for bounded takeover reconstruction - Primary-loss reconstruction from peer summaries (fail-closed gate) - In-process failover driver with session observability - Local boundary observations feed engine (Committed/Durable/Checkpoint) Design docs: - v2-two-loop-protocol.md: identity vs data-control separation - v2-automata-ownership-map.md: event/command ownership split - v2-loop1-surface-draft.md: heartbeat/query/assignment field spec - v2-volumev2-single-node-mvp.md: target layering - v2-kernel-closure-review.md: per-volume micro-cluster principle - v2-pure-runtime-rf1-bootstrap.md, v2-capability-map.md, v2-proof-and-retest-pyramid.md Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
46 lines
1.5 KiB
Go
46 lines
1.5 KiB
Go
package volumev2
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/seaweedfs/seaweedfs/sw-block/runtime/masterv2"
|
|
)
|
|
|
|
// ControlSession is the minimal control-plane contract between volumev2 and masterv2.
|
|
type ControlSession interface {
|
|
Heartbeat(masterv2.NodeHeartbeat) ([]masterv2.Assignment, error)
|
|
}
|
|
|
|
// PromotionEvidenceSource is the on-demand Loop 1 query surface used during
|
|
// failover arbitration.
|
|
type PromotionEvidenceSource interface {
|
|
QueryPromotionEvidence(masterv2.PromotionQueryRequest) (masterv2.PromotionQueryResponse, error)
|
|
}
|
|
|
|
// InProcessSession is the first in-process control-plane adapter used by the MVP.
|
|
type InProcessSession struct {
|
|
master *masterv2.Master
|
|
}
|
|
|
|
// NewInProcessSession creates a control session backed by one in-process masterv2.
|
|
func NewInProcessSession(master *masterv2.Master) (*InProcessSession, error) {
|
|
if master == nil {
|
|
return nil, fmt.Errorf("volumev2: master is nil")
|
|
}
|
|
return &InProcessSession{master: master}, nil
|
|
}
|
|
|
|
// Heartbeat sends one periodic heartbeat to masterv2 and returns the assignments to apply.
|
|
func (s *InProcessSession) Heartbeat(hb masterv2.NodeHeartbeat) ([]masterv2.Assignment, error) {
|
|
if s == nil || s.master == nil {
|
|
return nil, fmt.Errorf("volumev2: control session is nil")
|
|
}
|
|
return s.master.HandleHeartbeat(hb)
|
|
}
|
|
|
|
// Sync is retained as a narrow compatibility shim for existing tests while the
|
|
// three-channel Loop 1 surface settles.
|
|
func (s *InProcessSession) Sync(hb masterv2.NodeHeartbeat) ([]masterv2.Assignment, error) {
|
|
return s.Heartbeat(hb)
|
|
}
|