-
Notifications
You must be signed in to change notification settings - Fork 435
Add GRPCStreamStateMachine #1787
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
Merged
Merged
Changes from all commits
Commits
Show all changes
52 commits
Select commit
Hold shift + click to select a range
a663a27
Add client-side logic of GRPCStreamStateMachine
gjcairo 31f91f0
Add server-side logic to GRPCStreamStateMachine
gjcairo 6b5af81
Add individual state structs for each state
gjcairo 83fa5a8
Buffer inbound messages
gjcairo 3169e8b
Replace preconditionFailures with assertionFailure+error
gjcairo 406a5a9
Close (de)compressor when closing
gjcairo 55118b4
Add some tests and multiple refactors
gjcairo 5a29e51
Add validations to server-side receive metadata
gjcairo bf9ea2d
Tests for client side
gjcairo 1e78321
Tests for server side
gjcairo 89f3ea4
Multiple PR changes
gjcairo 21ac2d8
Fix encoding negotiation and return headers
gjcairo 35eef1a
Merge both state machines
gjcairo 1938ae2
More PR changes
gjcairo ed19ae7
Formatting
gjcairo c9d1eca
PR changes
gjcairo cf325f5
Refactor client tests
gjcairo 91ad5d8
More PR changes
gjcairo 4061768
Formatting
gjcairo e01293e
Refactor server tests
gjcairo d17103d
Add OnNextOutboundMessage
gjcairo 469806a
End (de)compressor at the right time
gjcairo d256376
Fix tests
gjcairo 4c91296
Small test refactor
gjcairo 389b6d5
Encode grpc status message in trailers
gjcairo 507018c
Draft new common paths tests
gjcairo 3219dc0
Formatting
gjcairo 2bff8ab
Don't allow server to end stream by sending a message
gjcairo 7396271
Small PR change
gjcairo 6ee3bd0
PR changes
gjcairo 67bfe05
Add tearDown method
gjcairo 2b58fd2
Fix tests and formatting
gjcairo 960af7c
PR changes
gjcairo 5697b1c
Disable swift-format rule
gjcairo 59793b6
Change import
gjcairo 72b0754
Remove some code duplication
gjcairo 2b383bd
Remove unnecessary special handling of status message in metadata
gjcairo ee12092
Remove redundant enum case
gjcairo 1e3c9dd
Change status code in error case when grpc-status is missing
gjcairo 1805b52
Avoid allocation
gjcairo cfa9ce2
Move state change outside of validation method
gjcairo 154e2c5
Remove unused code
gjcairo cec6788
Simplify compression state logic
gjcairo ed17c55
Formatting
gjcairo 627ce2a
Change some types to be fileprivate
gjcairo 54c8e1c
Remove some duplication
gjcairo 83661a1
Remove trailersOnly parameter from send(status:metadata:)
gjcairo 9aa7705
Formatting
gjcairo 61135de
Better handle invalid headers on client side
gjcairo 96c0f8a
Change order of required request headers
gjcairo c33dcc9
Fix server transition from idle to open when client is closed
gjcairo f8faf8a
Merge branch 'main' into stream-state-machine
glbrntt 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
52 changes: 52 additions & 0 deletions
52
Sources/GRPCHTTP2Core/Compression/CompressionAlgorithm.swift
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 |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| /* | ||
| * Copyright 2024, gRPC Authors All rights reserved. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| /// Supported message compression algorithms. | ||
| /// | ||
| /// These algorithms are indicated in the "grpc-encoding" header. As such, a lack of "grpc-encoding" | ||
| /// header indicates that there is no message compression. | ||
| public struct CompressionAlgorithm: Hashable, Sendable { | ||
| /// Identity compression; "no" compression but indicated via the "grpc-encoding" header. | ||
| public static let identity = CompressionAlgorithm(.identity) | ||
| public static let deflate = CompressionAlgorithm(.deflate) | ||
| public static let gzip = CompressionAlgorithm(.gzip) | ||
|
|
||
| // The order here is important: most compression to least. | ||
| public static let all: [CompressionAlgorithm] = [.gzip, .deflate, .identity] | ||
|
|
||
| public var name: String { | ||
| return self.algorithm.rawValue | ||
| } | ||
|
|
||
| internal enum Algorithm: String { | ||
| case identity | ||
| case deflate | ||
| case gzip | ||
| } | ||
|
|
||
| internal let algorithm: Algorithm | ||
|
|
||
| private init(_ algorithm: Algorithm) { | ||
| self.algorithm = algorithm | ||
| } | ||
|
|
||
| internal init?(rawValue: String) { | ||
| guard let algorithm = Algorithm(rawValue: rawValue) else { | ||
| return nil | ||
| } | ||
| self.algorithm = algorithm | ||
| } | ||
| } |
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.
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.
To align with other existing API https://developer.apple.com/documentation/foundation/data/2142853-base64encodedstring
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.
It's only a base64 encoded if the underlying value is
binaryso thebase64EncodedStringisn't accurate.