-
Notifications
You must be signed in to change notification settings - Fork 108
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
add support for ReadMaxBytes option #311
Conversation
f4d6b71
to
aff2dcf
Compare
Update connect-go to allow configuring a ReadMaxBytes option. This is useful to avoid excessive memory/cpu usage when dealing with very large messages.
64ecc86
to
d20f50a
Compare
Awesome, will try to review it tonight! @mattrobenolt FYI this should land soon. |
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.
This is excellent - I have literally nothing to add.
if err != nil { | ||
return errorf(CodeInvalidArgument, "message is larger than configured max %d - unable to determine message size: %w", readMaxBytes, err) | ||
} | ||
return errorf(CodeInvalidArgument, "message size %d is larger than configured max %d", bytesRead+discardedBytes, readMaxBytes) |
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.
Nice, love this! Good reason not to use discard
.
t.Helper() | ||
t.Run("equal_read_max", func(t *testing.T) { | ||
t.Parallel() | ||
// Serializes to exactly readMaxBytes (1024) - no errors expected |
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.
Excellent, glad you're testing this - looking at your code, I bet my previous implementation had an off-by-one error.
🤦🏽♂️ I didn't review this carefully enough. Per the gRPC specification, we should be using FYI, @mattrobenolt - there's a small change to this behavior incoming. |
Update connect-go to allow configuring a ReadMaxBytes option. This is useful to avoid excessive memory/cpu usage when dealing with very large messages.
Update connect-go to allow configuring a ReadMaxBytes option. This is
useful to avoid excessive memory/cpu usage when dealing with very large
messages.