googleapis / googleapis/google-cloud-node

Attach gRPC Metadata to Requests

Open
#7,369 1 comment 0 reactions 1 assignee Claimed by @alkatrivedi View on GitHub
api: spanner library: spanner priority: p3 type: feature request
Dominant language
TypeScript
Stars
3.2k
Forks
712
Avg merge
2d 3h
Merged PRs (30d)
99

Description

**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:

```javascript
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:

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

**Additional context**

The Spanner Go client already supports this:

```go
// package: google.golang.org/grpc/metadata
ctx := metadata.AppendToOutgoingContext(context.Background(), "key", "value")
client.Single().Query(ctx, stmt)
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.