Skip to content
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

Attach gRPC Metadata to Requests #2128

Open
iwinux opened this issue Sep 26, 2024 · 1 comment
Open

Attach gRPC Metadata to Requests #2128

iwinux opened this issue Sep 26, 2024 · 1 comment
Assignees
Labels
api: spanner Issues related to the googleapis/nodejs-spanner API. priority: p3 Desirable enhancement or fix. May not be included in next release. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@iwinux
Copy link

iwinux commented Sep 26, 2024

Is your feature request related to a problem? Please describe.

Under certain circumstances, we need to route Spanner queries via a gRPC proxy, which expects clients to provide some extra contexts to make better decisions.

However, currently the Spanner Node.js client has very limited ability to inject context:

  • transactionTag
  • requestTag

Describe the solution you'd like

gRPC metadata is the standard way to provide extra context for requests. In Node.js it is done like:

const meta = new grpc.Metadata()
meta.set('key', 'value')
service.method(payload, meta, ...)

It would be great if the Spanner client allows attaching gRPC Metadata to requests. For example:

database.run({
    sql: '...',
    requestOptions: { metadata: meta },
})

Additional context

The Spanner Go client already supports this:

// package: google.golang.org/grpc/metadata
ctx := metadata.AppendToOutgoingContext(context.Background(), "key", "value")
client.Single().Query(ctx, stmt)
@iwinux iwinux added priority: p3 Desirable enhancement or fix. May not be included in next release. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. labels Sep 26, 2024
@product-auto-label product-auto-label bot added the api: spanner Issues related to the googleapis/nodejs-spanner API. label Sep 26, 2024
@alkatrivedi alkatrivedi self-assigned this Oct 14, 2024
@alkatrivedi
Copy link
Contributor

Hi @iwinux, thanks for raising this request. Will raise a PR to fix this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: spanner Issues related to the googleapis/nodejs-spanner API. priority: p3 Desirable enhancement or fix. May not be included in next release. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
Development

No branches or pull requests

2 participants