-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
metadata: move FromOutgoingContextRaw() to internal #6765
Changes from 2 commits
c7d0145
208baa9
2b34f91
26a8b06
4494626
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -568,7 +568,8 @@ func (t *http2Client) createHeaderFields(ctx context.Context, callHdr *CallHdr) | |
headerFields = append(headerFields, hpack.HeaderField{Name: "grpc-trace-bin", Value: encodeBinHeader(b)}) | ||
} | ||
|
||
if md, added, ok := metadata.FromOutgoingContextRaw(ctx); ok { | ||
fromOutgoingCtxRaw := internal.FromOutgoingContextRaw.(func(context.Context) (metadata.MD, [][]string, bool)) | ||
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. Please instead do: package transport
var metadataFromOutgoingContextRaw = internal.FromOutgoingContextRaw.(func(context.Context) (metadata.MD, [][]string, bool)) and then use |
||
if md, added, ok := fromOutgoingCtxRaw(ctx); ok { | ||
var k string | ||
for k, vv := range md { | ||
// HTTP doesn't allow you to set pseudoheaders after non pseudoheaders were set. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,8 +25,14 @@ import ( | |
"context" | ||
"fmt" | ||
"strings" | ||
|
||
"google.golang.org/grpc/internal" | ||
) | ||
|
||
func init() { | ||
internal.FromOutgoingContextRaw = fromOutgoingContextRaw | ||
} | ||
|
||
// DecodeKeyValue returns k, v, nil. | ||
// | ||
// Deprecated: use k and v directly instead. | ||
|
@@ -238,7 +244,7 @@ func copyOf(v []string) []string { | |
return vals | ||
} | ||
|
||
// FromOutgoingContextRaw returns the un-merged, intermediary contents of rawMD. | ||
// fromOutgoingContextRaw returns the un-merged, intermediary contents of rawMD. | ||
// | ||
// Remember to perform strings.ToLower on the keys, for both the returned MD (MD | ||
// is a map, there's no guarantee it's created using our helper functions) and | ||
|
@@ -247,7 +253,7 @@ func copyOf(v []string) []string { | |
// | ||
// This is intended for gRPC-internal use ONLY. Users should use | ||
// FromOutgoingContext instead. | ||
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 can be removed now. |
||
func FromOutgoingContextRaw(ctx context.Context) (MD, [][]string, bool) { | ||
func fromOutgoingContextRaw(ctx context.Context) (MD, [][]string, bool) { | ||
raw, ok := ctx.Value(mdOutgoingKey{}).(rawMD) | ||
if !ok { | ||
return nil, nil, false | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -184,7 +184,8 @@ func newClientStream(ctx context.Context, desc *StreamDesc, cc *ClientConn, meth | |
// when the RPC completes. | ||
opts = append([]CallOption{OnFinish(func(error) { cc.idlenessMgr.OnCallEnd() })}, opts...) | ||
|
||
if md, added, ok := metadata.FromOutgoingContextRaw(ctx); ok { | ||
fromOutgoingCtxRaw := internal.FromOutgoingContextRaw.(func(context.Context) (metadata.MD, [][]string, bool)) | ||
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. Same as above with the transport package. |
||
if md, added, ok := fromOutgoingCtxRaw(ctx); ok { | ||
// validate md | ||
if err := imetadata.Validate(md); err != nil { | ||
return nil, status.Error(codes.Internal, err.Error()) | ||
|
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.
Please fix the formatting.