-
Notifications
You must be signed in to change notification settings - Fork 963
chore: add backed reader, writer and pipe implementation #19147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
9dd9c4a
to
3223bf9
Compare
d2ee08d
to
27da7ef
Compare
e5be506
to
77e912f
Compare
16abe05
to
dde9516
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not done with my review, but taking a break and wanted to send you comments so far.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another batch of comments.
I haven't really looked at BackedPipe yet, but I think maybe it would be better to wait for the comments I've made so far to be resolved.
require.NoError(t, err) | ||
} | ||
|
||
func TestBackedWriter_ConcurrentWrites(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The backed writer doesn't currently support concurrent writes (since it releases the mutex while writing).
But, it doesn't need to support writes concurrent with other writes --- we're only ever going to call write serially to send data we get from the reliable stream.
What we do need to care about is writes that are concurrent with Close
and Reconnect
.
Fixes: #18101
This PR introduces a new
backedpipe
package that provides reliable bidirectional byte streams over unreliable network connections. The implementation includes:BackedPipe
: Orchestrates a reader and writer to provide transparent reconnection and data replayBackedReader
: Handles reading with automatic reconnection, blocking reads when disconnectedBackedWriter
: Maintains a ring buffer of recent writes for replay during reconnectionRingBuffer
: Efficient circular buffer implementation for storing dataThe package enables resilient connections by tracking sequence numbers and replaying missed data after reconnection. It handles connection failures gracefully, automatically reconnecting and resuming data transfer from the appropriate point.