-
Notifications
You must be signed in to change notification settings - Fork 4.7k
grpc: support per-message compression and enforce embedding in ServerTransportStream implementations #8972
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
Open
Dostonlv
wants to merge
11
commits into
grpc:master
Choose a base branch
from
Dostonlv:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
grpc: support per-message compression and enforce embedding in ServerTransportStream implementations #8972
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
e311529
feat: add SetMessageCompression API to dynamically control per-messag…
Dostonlv 846f339
refactor: race cond
Dostonlv b1e38ee
grpc: fix conditional compression and update tests
Dostonlv 1feab8c
fix merge conflict
Dostonlv a7ff095
grpc: clean up SetMessageCompression API and tests
Dostonlv 99f8640
refactor: streamline compression handling in server and client streams
Dostonlv 731535b
grpc: split SetMessageCompression into server and client stream APIs
Dostonlv 489f488
grpc: rename doNotCompress to enableCompression and fix type assertion
Dostonlv 9e906cb
refactor: compressor tests moved and fixed review tasks
Dostonlv a8bf7be
update SetClientStreamMessageCompression to accept stream directly a…
Dostonlv 04e6bdc
review fixed
Dostonlv File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1470,7 +1470,11 @@ func (s *Server) processUnaryRPC(ctx context.Context, stream *transport.ServerSt | |
| if stream.SendCompress() != sendCompressorName { | ||
| comp = encoding.GetCompressor(stream.SendCompress()) | ||
| } | ||
| if err := s.sendResponse(ctx, stream, reply, cp, opts, comp); err != nil { | ||
| compV0, compV1 := cp, comp | ||
| if !stream.IsCompressionEnabled() { | ||
| compV0, compV1 = nil, nil | ||
| } | ||
|
Comment on lines
+1473
to
+1476
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This code is executed before the server handler is invoked. This would mean that stream.IsCompressionEnabled would always return true. Am I missing something here? Do we really need this check here? And if we really need this check, why is it missing for the streaming case? |
||
| if err := s.sendResponse(ctx, stream, reply, compV0, opts, compV1); err != nil { | ||
| if err == io.EOF { | ||
| // The entire stream is done (for unary RPC only). | ||
| return err | ||
|
|
@@ -1888,10 +1892,14 @@ func NewContextWithServerTransportStream(ctx context.Context, stream ServerTrans | |
| // Notice: This type is EXPERIMENTAL and may be changed or removed in a | ||
| // later release. | ||
| type ServerTransportStream interface { | ||
| internal.EnforceServerTransportStreamEmbedding | ||
| Method() string | ||
| SetHeader(md metadata.MD) error | ||
| SendHeader(md metadata.MD) error | ||
| SetTrailer(md metadata.MD) error | ||
| // EnableCompression controls whether per-message compression is enabled | ||
| // for subsequent messages sent on this stream. | ||
| EnableCompression(enable bool) | ||
| } | ||
|
|
||
| // ServerTransportStreamFromContext returns the ServerTransportStream saved in | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.