Skip to content

Commit

Permalink
feat(gengapic): use gax.InsertMetadataIntoOutgoingContext
Browse files Browse the repository at this point in the history
  • Loading branch information
quartzmo committed Jul 7, 2023
1 parent 9df02f0 commit e5d20e7
Show file tree
Hide file tree
Showing 28 changed files with 47 additions and 113 deletions.
12 changes: 0 additions & 12 deletions internal/gengapic/doc_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,18 +144,6 @@ func (g *generator) genDocFile(year int, scopes []string, serv *descriptor.Servi
p("}")
p("")

p("func insertMetadata(ctx context.Context, mds ...metadata.MD) context.Context {")
p(" out, _ := metadata.FromOutgoingContext(ctx)")
p(" out = out.Copy()")
p(" for _, md := range mds {")
p(" for k, v := range md {")
p(" out[k] = append(out[k], v...)")
p(" }")
p(" }")
p(" return metadata.NewOutgoingContext(ctx, out)")
p("}")
p("")

p("// DefaultAuthScopes reports the default set of authentication scopes to use with this package.")
p("func DefaultAuthScopes() []string {")
p(" return []string{")
Expand Down
10 changes: 6 additions & 4 deletions internal/gengapic/gengapic.go
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ func (g *generator) insertImplicitRequestHeaders(m *descriptor.MethodDescriptorP
// Trim the trailing comma and ampersand symbols.
f := formats.String()[:formats.Len()-1]
v := values.String()[:values.Len()-1]
g.printf("md := metadata.Pairs(\"x-goog-request-params\", fmt.Sprintf(%q,%s))", f, v)
g.printf("hds := []string{\"x-goog-request-params\", fmt.Sprintf(%q,%s)}", f, v)
return nil
}

Expand Down Expand Up @@ -355,7 +355,7 @@ func (g *generator) insertDynamicRequestHeaders(m *descriptor.MethodDescriptorPr
g.printf("}")
g.printf(`routingHeaders = strings.TrimSuffix(routingHeaders, "&")`)
g.imports[pbinfo.ImportSpec{Path: "strings"}] = true
g.printf("md := metadata.Pairs(\"x-goog-request-params\", routingHeaders)")
g.printf(`hds := []string{"x-goog-request-params", routingHeaders}`)
g.imports[pbinfo.ImportSpec{Path: "regexp"}] = true
return nil
}
Expand All @@ -380,8 +380,10 @@ func (g *generator) insertRequestHeaders(m *descriptor.MethodDescriptorProto, t
p("")
switch t {
case grpc:
p("ctx = insertMetadata(ctx, c.xGoogMetadata, md)")
p("hds = append(c.xGoogHeaders, hds...)")
p("ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)")
case rest:
p("md := metadata.Pairs(hds...)")
p(`headers := buildHeaders(ctx, c.xGoogMetadata, md, metadata.Pairs("Content-Type", "application/json"))`)
}
g.imports[pbinfo.ImportSpec{Path: "fmt"}] = true
Expand All @@ -391,7 +393,7 @@ func (g *generator) insertRequestHeaders(m *descriptor.MethodDescriptorProto, t
// No request-based header parameters.
switch t {
case grpc:
p("ctx = insertMetadata(ctx, c.xGoogMetadata)")
p("ctx = gax.InsertMetadataIntoOutgoingContext(ctx, c.xGoogHeaders...)")
case rest:
p(`headers := buildHeaders(ctx, c.xGoogMetadata, metadata.Pairs("Content-Type", "application/json"))`)
}
Expand Down
4 changes: 2 additions & 2 deletions internal/gengapic/gengrpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ func (g *generator) grpcClientInit(serv *descriptor.ServiceDescriptorProto, serv
g.mixinStubs()

p("// The x-goog-* metadata to be sent with each request.")
p("xGoogMetadata metadata.MD")
p("xGoogHeaders []string")

p("}")
p("")
Expand Down Expand Up @@ -378,7 +378,7 @@ func (g *generator) grpcClientUtilities(serv *descriptor.ServiceDescriptorProto,
p("func (c *%s) setGoogleClientInfo(keyval ...string) {", lowcaseServName)
p(` kv := append([]string{"gl-go", gax.GoVersion}, keyval...)`)
p(` kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "grpc", grpc.Version)`)
p(` c.xGoogMetadata = metadata.Pairs("x-goog-api-client", gax.XGoogHeader(kv...))`)
p(` c.xGoogHeaders = []string{"x-goog-api-client", gax.XGoogHeader(kv...)}`)
p("}")
p("")

Expand Down
4 changes: 2 additions & 2 deletions internal/gengapic/testdata/deprecated_client_init.want
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ type gRPCClient struct {
client mypackagepb.FooClient

// The x-goog-* metadata to be sent with each request.
xGoogMetadata metadata.MD
xGoogHeaders []string
}

// NewClient creates a new foo client based on gRPC.
Expand Down Expand Up @@ -115,7 +115,7 @@ func (c *gRPCClient) Connection() *grpc.ClientConn {
func (c *gRPCClient) setGoogleClientInfo(keyval ...string) {
kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "grpc", grpc.Version)
c.xGoogMetadata = metadata.Pairs("x-goog-api-client", gax.XGoogHeader(kv...))
c.xGoogHeaders = []string{"x-goog-api-client", gax.XGoogHeader(kv...)}
}

// Close closes the connection to the API service. The user should invoke this when
Expand Down
11 changes: 0 additions & 11 deletions internal/gengapic/testdata/doc_file.want
Original file line number Diff line number Diff line change
Expand Up @@ -108,17 +108,6 @@ func getVersionClient() string {
return versionClient
}

func insertMetadata(ctx context.Context, mds ...metadata.MD) context.Context {
out, _ := metadata.FromOutgoingContext(ctx)
out = out.Copy()
for _, md := range mds {
for k, v := range md {
out[k] = append(out[k], v...)
}
}
return metadata.NewOutgoingContext(ctx, out)
}

// DefaultAuthScopes reports the default set of authentication scopes to use with this package.
func DefaultAuthScopes() []string {
return []string{
Expand Down
11 changes: 0 additions & 11 deletions internal/gengapic/testdata/doc_file_alpha.want
Original file line number Diff line number Diff line change
Expand Up @@ -110,17 +110,6 @@ func getVersionClient() string {
return versionClient
}

func insertMetadata(ctx context.Context, mds ...metadata.MD) context.Context {
out, _ := metadata.FromOutgoingContext(ctx)
out = out.Copy()
for _, md := range mds {
for k, v := range md {
out[k] = append(out[k], v...)
}
}
return metadata.NewOutgoingContext(ctx, out)
}

// DefaultAuthScopes reports the default set of authentication scopes to use with this package.
func DefaultAuthScopes() []string {
return []string{
Expand Down
11 changes: 0 additions & 11 deletions internal/gengapic/testdata/doc_file_alpha_emptyservice.want
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,6 @@ func getVersionClient() string {
return versionClient
}

func insertMetadata(ctx context.Context, mds ...metadata.MD) context.Context {
out, _ := metadata.FromOutgoingContext(ctx)
out = out.Copy()
for _, md := range mds {
for k, v := range md {
out[k] = append(out[k], v...)
}
}
return metadata.NewOutgoingContext(ctx, out)
}

// DefaultAuthScopes reports the default set of authentication scopes to use with this package.
func DefaultAuthScopes() []string {
return []string{
Expand Down
11 changes: 0 additions & 11 deletions internal/gengapic/testdata/doc_file_beta.want
Original file line number Diff line number Diff line change
Expand Up @@ -110,17 +110,6 @@ func getVersionClient() string {
return versionClient
}

func insertMetadata(ctx context.Context, mds ...metadata.MD) context.Context {
out, _ := metadata.FromOutgoingContext(ctx)
out = out.Copy()
for _, md := range mds {
for k, v := range md {
out[k] = append(out[k], v...)
}
}
return metadata.NewOutgoingContext(ctx, out)
}

// DefaultAuthScopes reports the default set of authentication scopes to use with this package.
func DefaultAuthScopes() []string {
return []string{
Expand Down
11 changes: 0 additions & 11 deletions internal/gengapic/testdata/doc_file_beta_emptyservice.want
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,6 @@ func getVersionClient() string {
return versionClient
}

func insertMetadata(ctx context.Context, mds ...metadata.MD) context.Context {
out, _ := metadata.FromOutgoingContext(ctx)
out = out.Copy()
for _, md := range mds {
for k, v := range md {
out[k] = append(out[k], v...)
}
}
return metadata.NewOutgoingContext(ctx, out)
}

// DefaultAuthScopes reports the default set of authentication scopes to use with this package.
func DefaultAuthScopes() []string {
return []string{
Expand Down
11 changes: 0 additions & 11 deletions internal/gengapic/testdata/doc_file_emptyservice.want
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,6 @@ func getVersionClient() string {
return versionClient
}

func insertMetadata(ctx context.Context, mds ...metadata.MD) context.Context {
out, _ := metadata.FromOutgoingContext(ctx)
out = out.Copy()
for _, md := range mds {
for k, v := range md {
out[k] = append(out[k], v...)
}
}
return metadata.NewOutgoingContext(ctx, out)
}

// DefaultAuthScopes reports the default set of authentication scopes to use with this package.
func DefaultAuthScopes() []string {
return []string{
Expand Down
4 changes: 2 additions & 2 deletions internal/gengapic/testdata/empty_client_init.want
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ type gRPCClient struct {
client mypackagepb.FooClient

// The x-goog-* metadata to be sent with each request.
xGoogMetadata metadata.MD
xGoogHeaders []string
}

// NewClient creates a new foo client based on gRPC.
Expand Down Expand Up @@ -111,7 +111,7 @@ func (c *gRPCClient) Connection() *grpc.ClientConn {
func (c *gRPCClient) setGoogleClientInfo(keyval ...string) {
kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "grpc", grpc.Version)
c.xGoogMetadata = metadata.Pairs("x-goog-api-client", gax.XGoogHeader(kv...))
c.xGoogHeaders = []string{"x-goog-api-client", gax.XGoogHeader(kv...)}
}

// Close closes the connection to the API service. The user should invoke this when
Expand Down
4 changes: 2 additions & 2 deletions internal/gengapic/testdata/foo_client_init.want
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ type fooGRPCClient struct {
locationsClient locationpb.LocationsClient

// The x-goog-* metadata to be sent with each request.
xGoogMetadata metadata.MD
xGoogHeaders []string
}

// NewFooClient creates a new foo client based on gRPC.
Expand Down Expand Up @@ -142,7 +142,7 @@ func (c *fooGRPCClient) Connection() *grpc.ClientConn {
func (c *fooGRPCClient) setGoogleClientInfo(keyval ...string) {
kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "grpc", grpc.Version)
c.xGoogMetadata = metadata.Pairs("x-goog-api-client", gax.XGoogHeader(kv...))
c.xGoogHeaders = []string{"x-goog-api-client", gax.XGoogHeader(kv...)}
}

// Close closes the connection to the API service. The user should invoke this when
Expand Down
4 changes: 2 additions & 2 deletions internal/gengapic/testdata/lro_client_init.want
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ type fooGRPCClient struct {
operationsClient longrunningpb.OperationsClient

// The x-goog-* metadata to be sent with each request.
xGoogMetadata metadata.MD
xGoogHeaders []string
}

// NewFooClient creates a new foo client based on gRPC.
Expand Down Expand Up @@ -167,7 +167,7 @@ func (c *fooGRPCClient) Connection() *grpc.ClientConn {
func (c *fooGRPCClient) setGoogleClientInfo(keyval ...string) {
kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "grpc", grpc.Version)
c.xGoogMetadata = metadata.Pairs("x-goog-api-client", gax.XGoogHeader(kv...))
c.xGoogHeaders = []string{"x-goog-api-client", gax.XGoogHeader(kv...)}
}

// Close closes the connection to the API service. The user should invoke this when
Expand Down
2 changes: 1 addition & 1 deletion internal/gengapic/testdata/method_BidiThings.want
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
func (c *fooGRPCClient) BidiThings(ctx context.Context, opts ...gax.CallOption) (mypackagepb.Foo_BidiThingsClient, error) {
ctx = insertMetadata(ctx, c.xGoogMetadata)
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, c.xGoogHeaders...)
var resp mypackagepb.Foo_BidiThingsClient
opts = append((*c.CallOptions).BidiThings[0:len((*c.CallOptions).BidiThings):len((*c.CallOptions).BidiThings)], opts...)
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
Expand Down
2 changes: 1 addition & 1 deletion internal/gengapic/testdata/method_ClientThings.want
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
func (c *fooGRPCClient) ClientThings(ctx context.Context, opts ...gax.CallOption) (mypackagepb.Foo_ClientThingsClient, error) {
ctx = insertMetadata(ctx, c.xGoogMetadata)
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, c.xGoogHeaders...)
var resp mypackagepb.Foo_ClientThingsClient
opts = append((*c.CallOptions).ClientThings[0:len((*c.CallOptions).ClientThings):len((*c.CallOptions).ClientThings)], opts...)
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
Expand Down
2 changes: 1 addition & 1 deletion internal/gengapic/testdata/method_EmptyLRO.want
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
func (c *fooGRPCClient) EmptyLRO(ctx context.Context, req *mypackagepb.InputType, opts ...gax.CallOption) (*EmptyLROOperation, error) {
ctx = insertMetadata(ctx, c.xGoogMetadata)
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, c.xGoogHeaders...)
opts = append((*c.CallOptions).EmptyLRO[0:len((*c.CallOptions).EmptyLRO):len((*c.CallOptions).EmptyLRO)], opts...)
var resp *longrunningpb.Operation
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
Expand Down
5 changes: 3 additions & 2 deletions internal/gengapic/testdata/method_GetAnotherThing.want
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ func (c *fooGRPCClient) GetAnotherThing(ctx context.Context, req *mypackagepb.In
routingHeaders = fmt.Sprintf("%s%s=%s&", routingHeaders, headerName, headerValue)
}
routingHeaders = strings.TrimSuffix(routingHeaders, "&")
md := metadata.Pairs("x-goog-request-params", routingHeaders)
hds := []string{"x-goog-request-params", routingHeaders}

ctx = insertMetadata(ctx, c.xGoogMetadata, md)
hds = append(c.xGoogHeaders, hds...)
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
opts = append((*c.CallOptions).GetAnotherThing[0:len((*c.CallOptions).GetAnotherThing):len((*c.CallOptions).GetAnotherThing)], opts...)
var resp *mypackagepb.OutputType
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
Expand Down
5 changes: 3 additions & 2 deletions internal/gengapic/testdata/method_GetEmptyThing.want
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
func (c *fooGRPCClient) GetEmptyThing(ctx context.Context, req *mypackagepb.InputType, opts ...gax.CallOption) error {
md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v&%s=%v&%s=%v&%s=%v&%s=%v&%s=%v", "field_name.nested", url.QueryEscape(req.GetFieldName().GetNested()), "other", url.QueryEscape(req.GetOther()), "another", url.QueryEscape(req.GetAnother()), "biz", url.QueryEscape(fmt.Sprintf("%g", req.GetBiz())), "top_level_enum", mypackagepb.TopLevelEnum_name[int32(req.GetTopLevelEnum())], "nested_enum", mypackagepb.InputType_NestedEnum_name[int32(req.GetNestedEnum())]))
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v&%s=%v&%s=%v&%s=%v&%s=%v&%s=%v", "field_name.nested", url.QueryEscape(req.GetFieldName().GetNested()), "other", url.QueryEscape(req.GetOther()), "another", url.QueryEscape(req.GetAnother()), "biz", url.QueryEscape(fmt.Sprintf("%g", req.GetBiz())), "top_level_enum", mypackagepb.TopLevelEnum_name[int32(req.GetTopLevelEnum())], "nested_enum", mypackagepb.InputType_NestedEnum_name[int32(req.GetNestedEnum())])}

ctx = insertMetadata(ctx, c.xGoogMetadata, md)
hds = append(c.xGoogHeaders, hds...)
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
opts = append((*c.CallOptions).GetEmptyThing[0:len((*c.CallOptions).GetEmptyThing):len((*c.CallOptions).GetEmptyThing)], opts...)
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
var err error
Expand Down
2 changes: 1 addition & 1 deletion internal/gengapic/testdata/method_GetManyOtherThings.want
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
func (c *fooGRPCClient) GetManyOtherThings(ctx context.Context, req *mypackagepb.PageInputType, opts ...gax.CallOption) *StringIterator {
ctx = insertMetadata(ctx, c.xGoogMetadata)
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, c.xGoogHeaders...)
opts = append((*c.CallOptions).GetManyOtherThings[0:len((*c.CallOptions).GetManyOtherThings):len((*c.CallOptions).GetManyOtherThings)], opts...)
it := &StringIterator{}
req = proto.Clone(req).(*mypackagepb.PageInputType)
Expand Down
5 changes: 3 additions & 2 deletions internal/gengapic/testdata/method_GetManyThings.want
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
func (c *fooGRPCClient) GetManyThings(ctx context.Context, req *mypackagepb.PageInputType, opts ...gax.CallOption) *StringIterator {
md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v&%s=%v&%s=%v&%s=%v&%s=%v&%s=%v", "field_name.nested", url.QueryEscape(req.GetFieldName().GetNested()), "other", url.QueryEscape(req.GetOther()), "another", url.QueryEscape(req.GetAnother()), "biz", url.QueryEscape(fmt.Sprintf("%g", req.GetBiz())), "top_level_enum", mypackagepb.TopLevelEnum_name[int32(req.GetTopLevelEnum())], "nested_enum", mypackagepb.InputType_NestedEnum_name[int32(req.GetNestedEnum())]))
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v&%s=%v&%s=%v&%s=%v&%s=%v&%s=%v", "field_name.nested", url.QueryEscape(req.GetFieldName().GetNested()), "other", url.QueryEscape(req.GetOther()), "another", url.QueryEscape(req.GetAnother()), "biz", url.QueryEscape(fmt.Sprintf("%g", req.GetBiz())), "top_level_enum", mypackagepb.TopLevelEnum_name[int32(req.GetTopLevelEnum())], "nested_enum", mypackagepb.InputType_NestedEnum_name[int32(req.GetNestedEnum())])}

ctx = insertMetadata(ctx, c.xGoogMetadata, md)
hds = append(c.xGoogHeaders, hds...)
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
opts = append((*c.CallOptions).GetManyThings[0:len((*c.CallOptions).GetManyThings):len((*c.CallOptions).GetManyThings)], opts...)
it := &StringIterator{}
req = proto.Clone(req).(*mypackagepb.PageInputType)
Expand Down
5 changes: 3 additions & 2 deletions internal/gengapic/testdata/method_GetManyThingsOptional.want
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
func (c *fooGRPCClient) GetManyThingsOptional(ctx context.Context, req *mypackagepb.PageInputTypeOptional, opts ...gax.CallOption) *StringIterator {
md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v&%s=%v&%s=%v&%s=%v&%s=%v&%s=%v", "field_name.nested", url.QueryEscape(req.GetFieldName().GetNested()), "other", url.QueryEscape(req.GetOther()), "another", url.QueryEscape(req.GetAnother()), "biz", url.QueryEscape(fmt.Sprintf("%g", req.GetBiz())), "top_level_enum", mypackagepb.TopLevelEnum_name[int32(req.GetTopLevelEnum())], "nested_enum", mypackagepb.InputType_NestedEnum_name[int32(req.GetNestedEnum())]))
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v&%s=%v&%s=%v&%s=%v&%s=%v&%s=%v", "field_name.nested", url.QueryEscape(req.GetFieldName().GetNested()), "other", url.QueryEscape(req.GetOther()), "another", url.QueryEscape(req.GetAnother()), "biz", url.QueryEscape(fmt.Sprintf("%g", req.GetBiz())), "top_level_enum", mypackagepb.TopLevelEnum_name[int32(req.GetTopLevelEnum())], "nested_enum", mypackagepb.InputType_NestedEnum_name[int32(req.GetNestedEnum())])}

ctx = insertMetadata(ctx, c.xGoogMetadata, md)
hds = append(c.xGoogHeaders, hds...)
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
opts = append((*c.CallOptions).GetManyThingsOptional[0:len((*c.CallOptions).GetManyThingsOptional):len((*c.CallOptions).GetManyThingsOptional)], opts...)
it := &StringIterator{}
req = proto.Clone(req).(*mypackagepb.PageInputTypeOptional)
Expand Down
5 changes: 3 additions & 2 deletions internal/gengapic/testdata/method_GetOneThing.want
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
func (c *fooGRPCClient) GetOneThing(ctx context.Context, req *mypackagepb.InputType, opts ...gax.CallOption) (*mypackagepb.OutputType, error) {
md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v&%s=%v&%s=%v&%s=%v&%s=%v&%s=%v", "field_name.nested", url.QueryEscape(req.GetFieldName().GetNested()), "other", url.QueryEscape(req.GetOther()), "another", url.QueryEscape(req.GetAnother()), "biz", url.QueryEscape(fmt.Sprintf("%g", req.GetBiz())), "top_level_enum", mypackagepb.TopLevelEnum_name[int32(req.GetTopLevelEnum())], "nested_enum", mypackagepb.InputType_NestedEnum_name[int32(req.GetNestedEnum())]))
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v&%s=%v&%s=%v&%s=%v&%s=%v&%s=%v", "field_name.nested", url.QueryEscape(req.GetFieldName().GetNested()), "other", url.QueryEscape(req.GetOther()), "another", url.QueryEscape(req.GetAnother()), "biz", url.QueryEscape(fmt.Sprintf("%g", req.GetBiz())), "top_level_enum", mypackagepb.TopLevelEnum_name[int32(req.GetTopLevelEnum())], "nested_enum", mypackagepb.InputType_NestedEnum_name[int32(req.GetNestedEnum())])}

ctx = insertMetadata(ctx, c.xGoogMetadata, md)
hds = append(c.xGoogHeaders, hds...)
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
opts = append((*c.CallOptions).GetOneThing[0:len((*c.CallOptions).GetOneThing):len((*c.CallOptions).GetOneThing)], opts...)
var resp *mypackagepb.OutputType
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
Expand Down
2 changes: 1 addition & 1 deletion internal/gengapic/testdata/method_RespLRO.want
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
func (c *fooGRPCClient) RespLRO(ctx context.Context, req *mypackagepb.InputType, opts ...gax.CallOption) (*RespLROOperation, error) {
ctx = insertMetadata(ctx, c.xGoogMetadata)
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, c.xGoogHeaders...)
opts = append((*c.CallOptions).RespLRO[0:len((*c.CallOptions).RespLRO):len((*c.CallOptions).RespLRO)], opts...)
var resp *longrunningpb.Operation
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
Expand Down
5 changes: 3 additions & 2 deletions internal/gengapic/testdata/method_ServerThings.want
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
func (c *fooGRPCClient) ServerThings(ctx context.Context, req *mypackagepb.InputType, opts ...gax.CallOption) (mypackagepb.Foo_ServerThingsClient, error) {
md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v&%s=%v&%s=%v&%s=%v&%s=%v&%s=%v", "field_name.nested", url.QueryEscape(req.GetFieldName().GetNested()), "other", url.QueryEscape(req.GetOther()), "another", url.QueryEscape(req.GetAnother()), "biz", url.QueryEscape(fmt.Sprintf("%g", req.GetBiz())), "top_level_enum", mypackagepb.TopLevelEnum_name[int32(req.GetTopLevelEnum())], "nested_enum", mypackagepb.InputType_NestedEnum_name[int32(req.GetNestedEnum())]))
hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v&%s=%v&%s=%v&%s=%v&%s=%v&%s=%v", "field_name.nested", url.QueryEscape(req.GetFieldName().GetNested()), "other", url.QueryEscape(req.GetOther()), "another", url.QueryEscape(req.GetAnother()), "biz", url.QueryEscape(fmt.Sprintf("%g", req.GetBiz())), "top_level_enum", mypackagepb.TopLevelEnum_name[int32(req.GetTopLevelEnum())], "nested_enum", mypackagepb.InputType_NestedEnum_name[int32(req.GetNestedEnum())])}

ctx = insertMetadata(ctx, c.xGoogMetadata, md)
hds = append(c.xGoogHeaders, hds...)
ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
opts = append((*c.CallOptions).ServerThings[0:len((*c.CallOptions).ServerThings):len((*c.CallOptions).ServerThings)], opts...)
var resp mypackagepb.Foo_ServerThingsClient
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
Expand Down
Loading

0 comments on commit e5d20e7

Please sign in to comment.