feat(web): cluster page shows token ring — ring topology/leader/load, pending tasks, active forward topology with owner, incremental log sync view (e2e verified)

This commit is contained in:
2026-08-18 09:13:20 +08:00
parent 6959025219
commit bf602016b4
9 changed files with 217 additions and 138 deletions

View File

@ -78,12 +78,12 @@ type State struct {
// Token is the circulating message: one physical token, two phases per cycle.
type Token struct {
Cycle int64 `json:"cycle"`
Phase int `json:"phase"`
State State `json:"state"`
Cycle int64 `json:"cycle"`
Phase int `json:"phase"`
State State `json:"state"`
Log []LogEntry `json:"logDelta,omitempty"`
Passed []string `json:"passed,omitempty"`
SentAt int64 `json:"sentAt,omitempty"`
Passed []string `json:"passed,omitempty"`
SentAt int64 `json:"sentAt,omitempty"`
}
// ---- 环图操作 ---- //

View File

@ -41,8 +41,8 @@ type Engine struct {
send func(ctx context.Context, next string, tk *Token) error
// inflight tracks token-in-flight state (leader only).
inflight inFlight
Log *ClusterLog
inflight inFlight
Log *ClusterLog
lastLogSent int64
// lastRingStart time of the previous cycle launch (leader throttle).
lastRingStart time.Time

View File

@ -29,19 +29,19 @@ const (
// LogEntry is one immutable, append-only cluster operation.
type LogEntry struct {
Seq int64 `json:"seq"`
Node string `json:"node"`
Kind string `json:"kind"`
Data json.RawMessage `json:"data,omitempty"`
At int64 `json:"at"`
Seq int64 `json:"seq"`
Node string `json:"node"`
Kind string `json:"kind"`
Data json.RawMessage `json:"data,omitempty"`
At int64 `json:"at"`
}
// ClusterLog is a node's local operation log with a sync watermark.
type ClusterLog struct {
mu sync.Mutex
Seq int64 // highest local seq issued
Log []LogEntry // append-only
Synced int64 // watermark: entries <= this are known to remote nodes
mu sync.Mutex
Seq int64 // highest local seq issued
Log []LogEntry // append-only
Synced int64 // watermark: entries <= this are known to remote nodes
}
// NewClusterLog creates an empty log with initial sequence.