Skip to content

impl(bigtable): add RandomTwoLeastUsed stub decorator#16049

Merged
scotthart merged 1 commit intogoogleapis:mainfrom
scotthart:bigtable_random_two_decorator
Mar 19, 2026
Merged

impl(bigtable): add RandomTwoLeastUsed stub decorator#16049
scotthart merged 1 commit intogoogleapis:mainfrom
scotthart:bigtable_random_two_decorator

Conversation

@scotthart
Copy link
Member

Adds a BigtableStub decorator that holds the DynamicChannelPool object and wraps calls to the child stub with logic to increment and decrement the ChannelUsage RPC counter.

@scotthart scotthart requested a review from a team as a code owner March 18, 2026 23:24
@product-auto-label product-auto-label bot added the api: bigtable Issues related to the Bigtable API. label Mar 18, 2026
@gemini-code-assist
Copy link

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a new BigtableRandomTwoLeastUsed stub decorator for the Bigtable client library. This decorator is designed to work with the DynamicChannelPool to implement a load-balancing strategy that tracks the usage of underlying gRPC channels. By wrapping RPC calls, it ensures that channel usage is correctly accounted for, allowing the system to select the two least used channels for subsequent requests, thereby optimizing resource distribution.

Highlights

  • New Stub Decorator: Added a BigtableRandomTwoLeastUsed stub decorator to manage Bigtable RPCs.
  • Dynamic Channel Pool Integration: The decorator integrates with DynamicChannelPool to select channels based on usage.
  • Channel Usage Tracking: Implemented logic to increment and decrement ChannelUsage RPC counters for effective load balancing.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

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

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 a BigtableRandomTwoLeastUsed stub decorator. This decorator uses a DynamicChannelPool to select a stub for each RPC using a 'random two least used' strategy, and it correctly manages the usage count of stubs via AcquireStub and ReleaseStub calls. The implementation is well-structured, using helper templates to reduce boilerplate for unary, streaming, and async streaming RPCs. The new functionality is also accompanied by unit tests.

My main feedback is a suggestion to improve the robustness of the UnaryHelper function by using an RAII pattern to ensure resources are released even in the case of an exception, aligning it with the safer implementation of the streaming helpers.

@codecov
Copy link

codecov bot commented Mar 19, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.67%. Comparing base (98cabd9) to head (e821573).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #16049      +/-   ##
==========================================
- Coverage   92.68%   92.67%   -0.01%     
==========================================
  Files        2341     2342       +1     
  Lines      216206   216344     +138     
==========================================
+ Hits       200391   200503     +112     
- Misses      15815    15841      +26     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@scotthart scotthart merged commit 1841554 into googleapis:main Mar 19, 2026
53 of 60 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: bigtable Issues related to the Bigtable API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants