Skip to content

feat(firestore): add x-goog-is-transaction routing header - #36646

Open
nikhilchowdary wants to merge 3 commits into
googleapis:mainfrom
nikhilchowdary:feat-firestore-tx-routing-header
Open

nikhilchowdary wants to merge 3 commits into
googleapis:mainfrom
nikhilchowdary:feat-firestore-tx-routing-header

Conversation

@nikhilchowdary

Copy link
Copy Markdown

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

Add x-goog-is-transaction routing header in Ruby SDK to differentiate transactional requests and non-transactional requests from firestore. Having a routing header for transactions helps in routing grpc requests at GFE.
@nikhilchowdary
nikhilchowdary requested review from a team and yoshi-approver as code owners October 17, 2026 07:49
@quartzmo quartzmo self-assigned this Oct 19, 2026
@quartzmo

Copy link
Copy Markdown
Member

@nikhilchowdary Thanks for this PR. I'll contact you separately to discuss prioritization.

Comment thread google-cloud-firestore/lib/google/cloud/firestore/service.rb Outdated
@quartzmo quartzmo added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Oct 21, 2026
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Oct 21, 2026
end

def call_options parent: nil, token: nil
def call_options parent: nil, token: nil, is_transaction: false

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What do you think about passing the transaction itself instead of the computed boolean? Each call site already has transaction (or transaction_opt in begin_transaction), so call_options could implement the logic in one place:

    def call_options parent: nil, token: nil, transaction: nil
      Gapic::CallOptions.new(**{
        metadata:   default_headers(parent, transaction: transaction),
        page_token: token
      }.compact)
    end

    def default_headers parent = nil, transaction: nil
      parent ||= database_path
      routing_val = CGI.escapeURIComponent parent
      {
        "x-goog-request-params" => "database=#{routing_val}",
        "x-goog-is-transaction" => (!transaction.nil?).to_s
      }
    end

Call sites then read call_options(parent: database_path, transaction: transaction), and begin_transaction passes transaction: transaction_opt. The headers stay exactly the same, so the tests shouldn't need changes.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thanks for the suggestion. I have made the changes.

@quartzmo quartzmo added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Oct 21, 2026
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Oct 21, 2026

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants