feat(runner): add pull-dispatch coordination layer#55
Open
as535364 wants to merge 1 commit into
Open
Conversation
BackendClient (register/heartbeat), register_with_backoff (1-2-4-8-16-30s, 401 no-retry), HeartbeatThread (interval from register config, carries active_job_ids, 2x consecutive 401 fail-fast via on_fatal) and ActiveJobTracker. Dark slice - nothing wires into main.py yet; unit tests run without docker. Normal-OJ/Normal-OJ#68 (sandbox slice 2/4); spec section 10/13, ADR-0004
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Normal-OJ/Normal-OJ#68(sandbox slice 2/4)
新協調層
runner/,pull-based dispatch 的 runner 側基礎。Dark PR——main.py尚未接線,無任何呼叫者;不修改既有檔案。內容
runner/client.py—BackendClient(register/heartbeat,契約見 spec §7.1–7.2)、RunnerIdentity(memory-only,tokenrepr=False,ADR-0004)、RunnerConfig(parse register 回應的 config,缺 key 落 15/3/8 預設)runner/registration.py—register_with_backoff:backoff 1→2→4→8→16→30s(之後維持 30、無限重試);401 不重試直接 raiserunner/heartbeat.py—HeartbeatThread:interval 取自 register config(預設 15s)、body 夾帶ActiveJobTracker快照、連續 2 次 401 →on_fatal(非 401 結果歸零計數)、Event-based 可即時stop()runner/active_jobs.py—ActiveJobTracker:thread-safe add/remove(冪等)/snapshot/lenrunner/config.py—BACKEND_URL、RUNNER_REGISTRATION_TOKEN、RUNNER_NAME(未設時落 hostname)等;不動舊BACKEND_API測試
31 個單元測試,無 docker/網路依賴(注入 fake session):backoff 序列逐值驗證、401 fail-fast/歸零矩陣、request shape(URL/Bearer header/body)、config 預設值、tracker 冪等與 thread-safety、token 不出現在 repr。
備註
runner/→executor/改名)再 merge 本 PR,縮短runner/新舊檔案混居期;兩者無 git 衝突(本 PR 純新增檔案),順序僅影響可讀性。main.py接線與 Flask 移除為 keystone slice。docs/specs/pull-based-job-dispatch.md§10、§13;ADR-0004。