Repository navigation
watch: block-change events from the game server, with flood control - #3
Merged
Merged
Conversation
…ntrol to the queue
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.
TORO-Core の map-dirty モジュールからのブロック変更イベントを watch の待ち行列へ合流させ、洪水制御を加える。
イベント合流(scripts/job/dirty_feed.gd)
--dirty-portと token(TORO_DIRTY_TOKENか--dirty-token-file)がそろったときだけ WebSocket サーバーを開く。{"t":"auth","token":...}を送る。Godot の WebSocket サーバーは接続時のヘッダーを読めないため token はこの形で見せる(流儀自体は dynmap-live と同じ: 1 本の WebSocket と共有 token)。認証前の変更は捨て、token が違えば切る。{"t":"dirty","worlds":{...}}を受け、チャンクをワールド別に保持する。watch は周期の頭で取り出して待ち行列へ合流させる。合流規則は Anvil 検出と同じで、すでに入っているメガタイルは最初に入った時刻を保持する。イベント経由の再投入だけ「熱さ」を数える。洪水制御(scripts/job/watch_job.gd)
--mega-cooldown(既定 240 秒): 描いたメガはこの間は描き直さない。--stale-after-queueを超えて待ったものには適用しない(古いものを止め続けない)。--bbox-threshold(既定 256): 待ち行列がこれ以上になったマップは、優先順位をやめて範囲内の行順に処理する。対象は保持され、処理できた分だけ消える。--max-megas、転送速度)は変えていない。クールダウンと熱さは状態ファイル(watch-.json)に保存され、再起動しても残る。旧形式の状態ファイルもそのまま読める。テスト
godot --headless --path . -s tests/run_tests.gd: 163 checks, 0 failed(従来 134 + 新規 29: parse_dirty、認証の前後、合流の先着保持と熱さ、クールダウン、予約枠、熱い枠の上限、行順、状態の往復)。実クライアント(Python websockets)からの接続も確認済み: 正しい token では変更が 3 チャンク届き、間違った token では切断されて何も入らない。
ドキュメント(commands / architecture / operations)と compose の例にも使い方を追記した。本番への反映は TORO-Core 側 PR と揃えて別途計画する。