You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor(raft): extract drainSnapshotChunks to satisfy cyclop (PR #747 r3)
Round-3 lint feedback on commit 3424d5c from reviewdog/golangci:
> calculated cyclomatic complexity for function receiveSnapshotStream
> is 11, max is 10 (cyclop)
Round-3's EXDEV-avoidance change pushed receiveSnapshotStream's
cyclomatic complexity from 10 to 11 (the new spool-placement
branch). Reduced complexity by extracting two helpers and
narrowing each function's responsibility:
- snapshotSpoolPlacement(): owns the locked read of t.spoolDir /
t.fsmSnapDir and the EXDEV-avoidance decision (place spool
inside fsmSnapDir when wired). Returns (placement, fsmSnapDir).
- drainSnapshotChunks(): owns the per-chunk receive loop, CRC
accumulation, and the call into finalizeReceivedSnapshot on
the final chunk. Returns (msg, payloadBytes, err).
receiveSnapshotStream now owns:
- spool lifecycle (newSnapshotSpool + deferred Close-with-warn)
- the post-receive structured log line
Behaviour is byte-identical: same spool placement, same
finalization path, same log line (index, from, payload_bytes,
format).
Verified locally:
golangci-lint run --enable-only cyclop ./internal/raftengine/etcd/...
-- 0 issues.
Test:
go test -race -count=1 -short ./internal/raftengine/etcd
-- 12.0s, all green.
Claude bot round-3 review on the prior commit (3424d5c) marked
the PR as "approve. All three rounds of review concerns are
resolved." This refactor only addresses the cyclop signal raised
by reviewdog separately; no semantic changes on the receive
path. No caller audit needed.
0 commit comments