Skip to content

Attach gRPC Metadata to Requests #2128

@iwinux

Description

@iwinux

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)

Metadata

Metadata

Assignees

Labels

api: spannerIssues related to the googleapis/nodejs-spanner API.priority: p3Desirable enhancement or fix. May not be included in next release.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions