iox v0.3.4 — Fix ErrUnexpectedEOF contract for policy copy functions #24
hayabusa-cloud
announced in
Announcements
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Introduction
ioxprovides non-blocking I/O semantics for Go, extending the standardiopackage with first-class signals for would-block and partial-completion states.In traditional blocking I/O, operations either succeed or fail. Non-blocking I/O introduces a third state: "would block" — the operation cannot proceed right now but isn't a failure. Additionally, streaming operations may return "more" — progress was made, but the operation isn't finished. The
ioxpackage treats these states as control flow signals, not errors.The package defines two semantic errors:
ErrWouldBlock(no progress, retry later) andErrMore(progress made, more data available).The
Copyfamily of functions (Copy,CopyBuffer,CopyN,CopyBufferPolicy) preserve non-blocking semantics thatio.Copywould swallow. They supportWriterTo/ReaderFromfast paths and implement seeker rollback for partial writes, enabling safe retry without data loss.Usage
Highlights
CopyNPolicyandCopyNBufferPolicynow correctly returnio.ErrUnexpectedEOFwhen the source provides fewer bytes than requested, matching the contract established byCopyNandCopyNBuffer. The slow-path write loop incopyBufferPolicyalso gains rollback on wrapped semantic write errors, preventing potential data loss on seekable readers.What's Changed
Bug Fixes
CopyNPolicyandCopyNBufferPolicynow returnio.ErrUnexpectedEOFon short copies instead of(written, nil)— aligns withCopyN/CopyNBuffercontract (fix: return ErrUnexpectedEOF on short copies #23)copyBufferPolicyslow-path write loop now performs seeker rollback on wrapped semantic write errors, consistent withcopyBuffer(fix: return ErrUnexpectedEOF on short copies #23)Tests
CopyNPolicy,CopyNBufferPolicyerror passthrough, andcopyBufferPolicywrapped semantic error rollback (fix: return ErrUnexpectedEOF on short copies #23)Compatibility
This discussion was created from the release iox v0.3.4 — Fix ErrUnexpectedEOF contract for policy copy functions.
Beta Was this translation helpful? Give feedback.
All reactions