Repository navigation
refactor(writer): make the file-handle decision a pure function - #13
Merged
Merged
Conversation
The eviction fix from the previous commit had no regression test: exercising it end to end needs a handle idle past IDLE_TIMEOUT_SEC and a rewrite inside the 2s rollover window, which is unstable on CI. Extract the decision into session_file_action(session, handle_tracked, limit): missing handle or evicted handle -> reopen, size limit -> roll over, otherwise reuse. The writer maps the result to operations, and a plain unit test now covers all four cases, including the untracked handle that used to be written through. No behaviour change beyond the existing guard.
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.
上一个 PR 的驱逐修复没有回归测试:端到端复现需要句柄空闲超过 1s,同时第二次写又必须落在 2s rollover 窗口内,CI 上不稳定。
这次把决策抽出来:
写线程只负责把结果映射成动作,四种情况(含曾经会被直接写入的 untracked 句柄)现在由纯单测覆盖,不涉及线程和时间。
行为不变。