-
Notifications
You must be signed in to change notification settings - Fork 40
grpc: Add Call Metadata (Headers and Trailers) #517
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: grpc-common
Are you sure you want to change the base?
Conversation
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.
LGTM! Great work!
Couple of minor things below and a question:
Do you plan to add serializable versions of get/append/etc in a separate PR?
* | ||
* @param key the name of the metadata entry to retrieve (case-insensitive). Must not end with `-bin`. | ||
* @return the last value associated with the key, or `null` if no values exist | ||
* @throws IllegalArgumentException if the key ends with `-bin` |
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.
Probably also when the key doesn't conform to this:
Keys must contain only the following ASCII characters:
* - Digits: `0-9`
* - Lowercase letters: `a-z` (uppercase letters are normalized to lowercase)
* - Special characters: `-`, `_`, `.`
* | ||
* ## Example usage | ||
* ```kotlin | ||
* val metadata = GrpcMetadata().apply { |
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.
Let's also add buildGrpcMetadata(body)
method, which does the same as GrpcMetadata().apply { body() }
import libkgrpc.kgrpc_metadata_array_append | ||
import kotlin.experimental.ExperimentalNativeApi | ||
|
||
private value class GrpcKey private constructor(val name: String) { |
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.
Probably better to call it GrpcMetadataKey
even if it is private
@InternalRpcApi | ||
public actual typealias GrpcMetadata = io.grpc.Metadata | ||
|
||
public actual operator fun GrpcMetadata.get(key: String): String? { |
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.
Does java lib perform ascii validation?
Subsystem
gRPC
Problem Description
Before this, we had no support for passing gRPC metadata between the client and the server.
Solution
This PR solves this on JVM and Native by providing a custom interface (
GrpcMetadata
).