Skip to content

Emit header for gRPC messages #869

Description

@pcostell

gRPC connections currently don't have enough information in the request for us to do efficient traffic management/routing.

Will you add a header that allows for us to optimize for this on the server? The header format is:

name: google-cloud-resource-prefix
value: projects/my-project-id

In general, the prefix would be the same as the JSON-over-http URL up to any custom method. For example, a Cloud Datastore commit message over JSON would hit the url projects/my-project-id:commit.

Here is an example usage in the cloud-bigtable-client: https://github.com/GoogleCloudPlatform/cloud-bigtable-client/pull/915/files#diff-1078787e69bc1d7c5bb8507f0a87a143R83

Activity

  1. blowmage commented on Sep 4, 2016

    @blowmage
    Contributor

    Is this needed just for Datastore? Or does every service using GRPC to connect need this as well?

  2. pcostell commented on Sep 4, 2016

    @pcostell
    ContributorAuthor

    This will be needed for all services though we are working with the gRPC team to expose this information automatically.

    /cc @eddavisson

  3. eddavisson commented on Sep 6, 2016

    @eddavisson

    As @pcostell notes, our eventual goal is to build this into the gRPC layer, but we'd like to get something in place in the meantime.

  4. blowmage commented on Sep 8, 2016

    @blowmage
    Contributor

    I thought I understood how to set custom headers in the GRPC client, but it turns out I was confused. Can you point us to some documentation on configuring the GRPC client or making API calls with custom headers? @jmuk is there anything in GAX that exposes this?

  5. jmuk commented on Sep 9, 2016

    @jmuk
    Contributor

    It seems a bit obscure, but gRPC sends the custom metadata as the headers, see https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-HTTP2.md

    Metadata can be specified for individual method call with optional metadata: parameter. For Ruby, the keys are Symbol for some reasons, and the values are string.

    In GAX, CallOptions has kwargs which are (I think) used as the HTTP headers in gRPC:

    So you can use that if you're using GAX.

    Unfortunately this can't be customized at the constructor of the generated files, so you will have to specify on the every method call.

  6. quartzmo commented on Sep 9, 2016

    @quartzmo
    Member

    Thank you @jmuk! That is very helpful.

  7. self-assigned this
    on Oct 10, 2016
  8. modified the milestone: v0.21 on Oct 10, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions