mirror of
https://gitcode.com/JianFeeeee/webui4frpc.git
synced 2026-09-21 09:27:57 +00:00
feat(M6): token-ring protocol complete — task ride+lowest-load claim, topology publish back to token, real worker spawn via claim, incremental log sync e2e
This commit is contained in:
@ -6,6 +6,8 @@ import (
|
||||
"context"
|
||||
"log"
|
||||
"time"
|
||||
|
||||
"webui4frpc/internal/store"
|
||||
)
|
||||
|
||||
// Phase constants for the two-round cycle.
|
||||
@ -159,7 +161,10 @@ func (e *Engine) phase2(ctx context.Context, tk *Token) error {
|
||||
}
|
||||
e.state.AddTopology(claimed, e.ID)
|
||||
}
|
||||
e.state = tk.State
|
||||
// Publish our updated state back into the token so the next node carries
|
||||
// the fresh topology + pending set (do NOT revert local state to the
|
||||
// incoming snapshot — that would discard the claim we just made).
|
||||
tk.State = e.state
|
||||
tk.Passed = append(tk.Passed, e.ID)
|
||||
return nil
|
||||
}
|
||||
@ -359,6 +364,12 @@ func (e *Engine) AdoptState(s State) {
|
||||
}
|
||||
}
|
||||
|
||||
// SubmitTask adds a new forward request to pending; it rides the next token
|
||||
// round and is claimed by the lowest-load member.
|
||||
func (e *Engine) SubmitTask(local store.Local, remote store.Remote, link store.Link) *Task {
|
||||
return e.state.AddPending(local, remote, link)
|
||||
}
|
||||
|
||||
// IsLeader reports whether this node is the current ring leader.
|
||||
func (e *Engine) IsLeader() bool { return e.state.LeaderID == e.ID }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user