Skip to content

feat(datastore): add x-goog-is-transaction routing header - #9724

Open
nikhilchowdary wants to merge 3 commits into
googleapis:mainfrom
nikhilchowdary:feat/datastore-is-transaction-header
Open

nikhilchowdary wants to merge 3 commits into
googleapis:mainfrom
nikhilchowdary:feat/datastore-is-transaction-header

Conversation

@nikhilchowdary

@nikhilchowdary nikhilchowdary commented Oct 25, 2026 •

Copy link
Copy Markdown

Add x-goog-is-transaction routing header in nodejs SDK to differentiate transactional requests and non-transactional requests from each other. Having a routing header for transactions helps in routing grpc requests at GFE.

This commit attaches the x-goog-is-transaction routing header to all RPCs

  • Set to true for transactional RPCs
    -- beginTransaction
    -- rollback
    -- transactional commit
    -- transactional lookup
    -- transactional runQuery
    -- transactional runAggregationQuery.

  • Set to false for non transactional RPCs
    -- allocateIds
    -- non transactional commit
    -- non transactional lookup
    -- non transactional runQuery
    -- non transactional runAggregationQuery.

cc: @MarkDuckworth

@nikhilchowdary
nikhilchowdary requested a review from a team as a code owner October 25, 2026 06:58
@product-auto-label product-auto-label Bot added the api: datastore Issues related to the Datastore API. label Oct 25, 2026
@github-actions
github-actions Bot requested a review from danieljbruce October 25, 2026 06:58

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces logic to determine if a Datastore request is transactional and sets the x-goog-is-transaction header accordingly, along with comprehensive unit tests. The feedback suggests refining the transaction detection logic to correctly handle the enum representation of NON_TRANSACTIONAL in addition to its string value, and adding a corresponding test case to prevent regressions.

Comment thread handwritten/datastore/src/request.ts Resolved
Comment thread handwritten/datastore/test/request.ts Resolved
@nikhilchowdary
nikhilchowdary force-pushed the feat/datastore-is-transaction-header branch 3 times, most recently from 47b64a2 to 42e3419 Compare October 26, 2026 08:52
Adds the `x-goog-is-transaction: true` HTTP header to all transactional
Datastore RPCs, ensuring proper routing of transactional requests.

Changes:
- Modified `prepareGaxRequest_` in `request.ts` to calculate `isTransactionHeader` based on the RPC method (`beginTransaction`, `rollback`, or `commit`, `runQuery`, etc.) and the transaction ID presence.
- Appended the header `x-goog-is-transaction` to GAX options for all calls (set to `true` or `false`).
- Added exhaustive unit tests in `request.ts` that verify the `x-goog-is-transaction` header behavior for both transactional and non-transactional RPC calls.
@nikhilchowdary
nikhilchowdary force-pushed the feat/datastore-is-transaction-header branch from 42e3419 to 0ee4527 Compare October 26, 2026 09:21

@danieljbruce danieljbruce left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Just adding a before/after matrix for posterity:

Image

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: datastore Issues related to the Datastore API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants